| Date: | Thu, 8 Jul 2004 13:32:19 -0400 |
| Reply-To: | Richard Ristow <wrristow@mindspring.com> |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | Richard Ristow <wrristow@mindspring.com> |
| Subject: | Re: Reshapind data |
|
| In-Reply-To: | <F062093E456F8C4A9566C5CA59726C6E01F59AFA@EMAIL.hci.utah.ed u> |
| Content-Type: | text/plain; charset="us-ascii"; format=flowed |
|---|
At 12:19 PM 7/8/2004, Jose G. Benuzillo wrote:
>I wonder if anyone can help me reshaping my data.
>
>Id numkids age1 age2 age3 age4 age5
>01 1 10 . . . .
>02 2 11 15 . . .
>03 3 10 11 12 . .
>04 2 15 . . . .
>05 3 . . . . .
>I would like to have one variable for age according to the number of children.
That is, it seems, one record for each child, with the (family) ID and the
child's age, which may be missing.
It's a nice little exercise in LOOP and XSAVE. I've added BIRTHORD to the
output file, so records will be uniquely identified. Tested; this is SPSS
draft output:
LIST.
List
ID NUMKIDS AGE1 AGE2 AGE3 AGE4 AGE5
01 1 10 . . . .
02 2 11 15 . . .
03 3 10 11 12 . .
04 2 15 . . . .
05 3 . . . . .
VECTOR AGE_N=AGE1 TO AGE5.
NUMERIC BIRTHORD AGE (F2).
VAR LABELS
BIRTHORD "Child's birth order in family"
AGE "Child's age"
ID "Family number".
LOOP BIRTHORD = 1 to NUMKIDS.
. COMPUTE AGE= AGE_N(BIRTHORD).
. XSAVE OUTFILE='c:\TempStor\SPSS\2004-07-08 Benuzillo-reshape.SAV'
/KEEP = ID BIRTHORD AGE.
END LOOP.
EXECUTE.
GET FILE='c:\TempStor\SPSS\2004-07-08 Benuzillo-reshape.SAV'.
LIST.
List
ID BIRTHORD AGE
01 1 10
02 1 11
02 2 15
03 1 10
03 2 11
03 3 12
04 1 15
04 2 .
05 1 .
05 2 .
05 3 .
Number of cases read: 11 Number of cases listed: 11
|