Date: Wed, 2 Jul 2008 12:35:13 +0200
Reply-To: Marta García-Granero <email@example.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Marta García-Granero <firstname.lastname@example.org>
Subject: Re: selecting cases???????
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> All I need to delete is cases 'D' and 'E' and hence the sequence
> (2003,2004,2005,2003,2004,2005,..........it goes like that) is kept
> intact. You were wondering if the range is between 2003 and 2005.
> well that is right. there are only 2003,2004 and 2005. I just need to
> keep the sequence and delete the rest which are in between that does
> follow the order.
I have added some cases to your sample dataset just to be ready to deal
with other "out of sequence" data, like 2003 followed by 2005 (see ID
"O" & "P"), besides the case you presented (2004 without a 2003 before,
like in ID "D" & "E").
* Sample dataset *.
DATA LIST LIST/ID(A1) year(F8).
* This part flags sequences not starting with 2003 *.
DO IF Flag NE 1.
- IF (year=2004) AND (LAG(year,1)=2003) Flag=1.
- IF (year=2005) AND (LAG(year,2)=2003) Flag=1.
* This part flags sequences starting with 2003 not followed by 2004 *.
SORT CASES BY ID(D).
IF (year=2003) AND (LAG(year) NE 2004) Flag=0.
* Now we get rid of every flag=0 data *.
EXE. /*don't eliminate it *.
SELECT IF Flag=1.
SORT CASES BY ID(A).
DELETE VARIABLES Flag.
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
For a list of commands to manage subscriptions, send the command