Date: Tue, 20 Apr 2004 14:13:55 -0400
Reply-To: Richard Ristow <wrristow@mindspring.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <wrristow@mindspring.com>
Subject: Re: Increasing a variable
In-Reply-To: <4D7CB3BFC594D61183630002A534A6252E5962@cdcmail.cdc>
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 05:49 AM 4/19/2004, Kamau, Patrick wrote:
>I have a variable called 'return visits' that takes care of clients
>who have come for another visit. For the initial visit, return
>visit=0 and subsequent returns visits=1.
>
>I would like to have increasing numbers showing the real return, using
>the date or month, i.e.
>First visit =0
>Second visit =1
>Third visit =2 etc.
>Your help will be appreciated.
Jan Spousta had one interpretation of this. Here's a different one; is
this what you were looking for? It does NOT use your original "return
visit" variable at all.
Assuming
. Client is identified by a variable named CLIENTID
. Visit date is an SPSS date variable, VIS_DATE.
. Your file is the SPSS working data file
/* The SORT is not necessary if your data is already sorted */
SORT CASES BY CLIENTID VIS_DATE.
NUMERIC RTRN_VIS (F2).
VARIABLE LABELS
RTRN_VIS 'Return visit # (0=initial visit').
DO IF $CASENUM = 1.
. COMPUTE RTRN_VIS = 0.
ELSE IF CLIENTID NE LAG(CLIENTID).
. COMPUTE RTRN_VIS = 0.
ELSE.
. COMPUTE RTRN_VIS = LAG(RTRN_VIS) + 1.
END IF.