Recode with IF function

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

oken
Posts: 9
Joined: Thu Nov 10, 2011 7:26 am

Recode with IF function

Postby oken » Tue Nov 12, 2013 11:13 am

I am trying to recode into a new variable using the syntax below

DO IF (Q14_1 = 0).
RECODE Q24_A (ELSE=88).
END IF.
EXECUTE.

But the software would not even bulge. What might be wrong?
pythonforspss.org
Posts: 116
Joined: Sat Oct 06, 2012 6:21 am

Re: Recode with IF function

Postby pythonforspss.org » Tue Nov 12, 2013 11:45 am

Perhaps Q24_A doesn't exist yet? The RECODE you use is for recoding into the same variable. And you don't seem to need DO IF ... END IF. Try this

Code: Select all

if Q14_1 = 0 Q24_A = 88.
freq Q24_A.
Do note that Q24_A will hold system missings for all cases that don't have Q14_1 = 0 (if it didn't exist yet). You could also try

Code: Select all

recode Q14_1 (else=88) into Q24_A.
freq Q24_A.
Kind regards,

Ruben Geert van den Berg
http://www.spss-tutorials.com
oken
Posts: 9
Joined: Thu Nov 10, 2011 7:26 am

Re: Recode with IF function

Postby oken » Thu Nov 14, 2013 8:44 am

What happened is that Q_14 asked if a household had pregnant women in the house and q_24 asked if the pregnant woman slept under insecticide night the previous night. I wanted to recode q24 such that if q14 had been 0 (No pregnant woman) then q24 would be 8 (No pregnant woman, which would be declared missing). But SPSS 15 and 20 would not bulge.
pythonforspss.org
Posts: 116
Joined: Sat Oct 06, 2012 6:21 am

Re: Recode with IF function

Postby pythonforspss.org » Thu Nov 14, 2013 5:46 pm

Then you should slightly correct the syntax I proposed. What happens if you run it?
Kind regards,

Ruben Geert van den Berg
http://www.spss-tutorials.com

Who is online

Users browsing this forum: No registered users and 1 guest

cron