Date: Mon, 4 Apr 2005 13:01:56 -0400
Reply-To: Doug Fuller <dfuller@wayne.edu>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Doug Fuller <dfuller@wayne.edu>
Subject: Re: Lag
Content-Type: text/plain; charset=us-ascii
>I have variables ordered by record (event), rather than by
>subject.
>
>I am trying to create a second variable that uniquely
>identifies which event it is for the participant, such that
>participant 1540 would receive a 1 in row 1, a 2 in row 2
>and so on for 1544 who would receive 1, 2 and then 3.
Not tested on a production dataset, but works on the
following sample, assuming cases are sorted by ID:
ID
1
1
1
2
2
3
4
4
5
5
5
5
compute dupe = 1.
if ((lag(id) = id) and (lag(dupe) ge 1)) dupe = lag(dupe) + 1.
exe.
list vars id dupe.
ID DUPE
1.00 1.00
1.00 2.00
1.00 3.00
2.00 1.00
2.00 2.00
3.00 1.00
4.00 1.00
4.00 2.00
5.00 1.00
5.00 2.00
5.00 3.00
5.00 4.00
Number of cases read: 12
Number of cases listed: 12
Hope this helps!
Best,
--
Doug Fuller
dfuller@wayne.edu
Research Assistant, Wayne State University
Department of Psychiatry and Behavioral Neurosciences