|
I didn't capture one aspect clearly. In the groups of records identified by
casenum, only one record in some of the groups has a 1 in it. I need to
capture all the records associated with that record according to casenum.
Thanks.
-----Original Message-----
From: Richard Ristow [mailto:wrristow@mindspring.com]
Sent: Wednesday, October 22, 2003 7:13 PM
To: Raffe, Sydelle, SSA; SPSSX-L@LISTSERV.UGA.EDU
Subject: Re: data structure.xls
At 01:20 PM 10/22/2003 -0700, Raffe, Sydelle, SSA wrote:
>I have a file wherein records are keyed together by
>"casenum". Casenum groups can be from 2 to 16(highly unlikely)
>records. I need to identify groups of records with the same casenum
>where there is a code 1 in the last column.
>
>I'd like to end up with an excel data base with only those groups of
>records keyed by casenum where there is a one in that column (variable).
Well, in SPSS this is easy with AGGREGATE/MATCH FILES. I'll let you
move it to Excel yourself.
If I have this right, you want all records where *any* record with the
same "casenum" has a 1 in a variable I'll call LASTCOL.
This is untested code. I assume you can write scratch files freely to
c:\TEMP.
*----------------------------------------------.
SORT CASES BY CASENUM. /* Put groups together */
TEMPORARY.
COMPUTE LAST_IS1 = 0.
IF (LASTCOL = 1) LAST_IS1 = 1.
AGGREGATE/OUTFILE='c:\TEMP\KEEP_GRP.SAV'
/BREAK= CASENUM
/KEEP_GRP = MAX(LAST_IS1).
MATCH FILES/FILE=*/FILE='c:\TEMP\KEEP_GRP.SAV'
/BY CASENUM.
SELECT IF (KEEP_GRP = 1).
*----------------------------------------------.
There are variations, of course, but this should work quickly and easily.
|