Many thanks to Bruce, Hillel, David and others for their help in solving
this problem. Hillel's and David's fantastic syntax is posted below:
From Hillel Vardi:
DATA LIST fixed / id date q1 q2 q3 (f2 1x adate10 3f3) .
BEGIN DATA
1 08/08/2004 12 15 23
1 10/08/2004 10 14 24
1 12/22/2004 13 13 29
1 02/27/2004 20 16 20
1 05/08/2005 18 17 21
1 12/24/2006 20 11 19
1 01/08/2007 18 14 21
END DATA.
add files file=* / by id / first=first.
compute days= datedeff(date,date.dmy(1,1,2000),'days') .
if first eq 1 testday=days.
if first eq 1 seq=1.
leave testday seq .
do if days-testday lt 90 .
compute keep=0 .
else if days-testday ge 90 .
compute keep=1.
compute testday=days .
compute seq=sum(seq,1) .
end if.
if first eq 1 keep=1.
execute .
select if keep eq 1.
SORT CASES BY id seq.
CASESTOVARS
/ID=id
/INDEX=seq
/drop=first keep testday days
/GROUPBY = INDEX .
From David Marso:
Leaving out the CASESTOVARS.
DO IF ID<> LAG(ID) OR $CASENUM=1.
+ COMPUTE REFDATE=date.
+ COMPUTE RETAIN=1.
ELSE.
+ COMPUTE refdate=LAG(refdate).
+ COMPUTE DELTA=CTIME.DAYS(date-refdate).
+ DO IF (DELTA >= 90).
+ COMPUTE RETAIN=1.
+ COMPUTE refdate=date.
+ END IF.
END IF.
EXE.
SELECT IF RETAIN.
MATCH FILES / FILE * / DROP refdate retain delta.
On Sat, 5 Nov 2005 18:56:40 -0500, Anton <
[hidden email]> wrote:
>Dear Listers-
>
>I have a data set with three variables (ID, Count, Date) that I would like
>to restructure (disaggregate?) into two variables (ID, Date). Each ID
>occurs multiple times. Count refers to the number of episodes occuring on
>each date.
>
>In other words, I want to go from this:
>
>67 3 05/06/2004
>67 2 05/22/2004
>11 2 06/05/2004
>11 1 12/12/2004
>98 2 11/23/2005
>
>
>To something like this:
>
>67 05/06/2004
>67 05/06/2004
>67 05/06/2004
>67 05/22/2004
>67 05/22/2004
>11 06/05/2004
>11 06/05/2004
>11 12/12/2004
>98 11/23/2005
>98 11/23/2005
>
>I have been using restructure from the drop-down menu and still can't quite
>get it right.
>
>Thanks in advance for your help.
>
>Anton
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD