Date: Fri, 9 Sep 2005 09:38:06 -0500
Reply-To: "Marks, Jim" <Jim.Marks@lodgenet.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Marks, Jim" <Jim.Marks@lodgenet.com>
Subject: Re: Explaining output of a do if with missing values
Content-Type: text/plain; charset="us-ascii"
Martin:
I guess that the cases with race = 3 are passed along for later
processing, even when sex is missing.
They get past the ELSE command, even when sex is missing.
The cases with race = 1 or 2 and sex missing all fail in the earlier DO
IF/ ELSE IF statements.
You can use RECODE within a DO IF structure:
e.g.
DO IF SYSMIS(race) OR SYSMIS (sex).
RECODE racesex (ELSE=SYSMIS).
END IF.
--jim
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Martin Sherman
Sent: Friday, September 09, 2005 8:59 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Explaining output of a do if with missing values
Dear list, I have the following syntax program along with the output.
What I don't understand
is why if Race eq 3 and sex is missing then racesex eq 5 but when sex
eq 1 and race is missing then racesex eq missing. What am I missing.
thanks, martin sherman
data list free / race sex.
begin data
1 1
. 1
1 2
1 2
2 1
2 1
2 .
2 2
3 1
3 1
3 2
3 2
. .
3 .
4 1
4 2
4 2
5 1
. 1
5 2
end data.
do if (race eq 1 and sex eq 1).
compute racesex=1.
else if (race eq 1 and sex eq 2).
compute racesex=2.
else if (race eq 2 and sex eq 1).
compute racesex=3.
else if (race eq 2 and sex eq 2).
compute racesex=4.
else.
compute racesex=5.
end if.
list race sex racesex.
1.00 1.00 1.00
. 1.00 .
1.00 2.00 2.00
1.00 2.00 2.00
2.00 1.00 3.00
2.00 1.00 3.00
2.00 . .
2.00 2.00 4.00
3.00 1.00 5.00
3.00 1.00 5.00
3.00 2.00 5.00
3.00 2.00 5.00
. . .
3.00 . 5.00
4.00 1.00 5.00
4.00 2.00 5.00
4.00 2.00 5.00
5.00 1.00 5.00
. 1.00 .
5.00 2.00 5.00