|
At 01:47 PM 10/31/2006, Steven K. Erickson wrote:
>I know that in SAS I would run:
>
>data small;
>set big;
>by id;
>if arrest=1;
>if first.id then output;
>run;
Sure. The following ADD FILES and SELECT IF constitute a direct
translation, except
. it reads from, and writes to, the current working dataset (working
file), rather than named datasets 'big' and 'small'
. it leaves variable FIRST_ID in the output file
Both the SAS and the SPSS code assume that
. The input file is sorted by ID
. Within ID, it's sorted so that selecting the first case found is
acceptable
This is tested; SPSS draft output. (To myself: code and listing not
kept separately. Data hand-entered in Data Editor; no raw data or input
code.)
* .................. .
LIST.
|-----------------------------|---------------------------|
|Output Created |31-OCT-2006 14:26:38 |
|-----------------------------|---------------------------|
ID Letter
1 Alpha
1 Beta
1 Gamma
2 Delta
2 Epsilon
3 Zeta
3 Eta
3 Theta
3 Iota
Number of cases read: 9 Number of cases listed: 9
ADD FILES
/FILE=*
/BY ID
/FIRST=FIRST_ID.
SELECT IF FIRST_ID.
LIST.
|-----------------------------|---------------------------|
|Output Created |31-OCT-2006 14:26:38 |
|-----------------------------|---------------------------|
ID Letter FIRST_ID
1 Alpha 1
2 Delta 1
3 Zeta 1
Number of cases read: 3 Number of cases listed: 3
|