Date: Tue, 21 Sep 2010 08:19:48 -0700
Reply-To: Bruce Weaver <bruce.weaver@hotmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Bruce Weaver <bruce.weaver@hotmail.com>
Subject: Re: FW: Compute / generate a new variable
In-Reply-To: <SNT123-W35A7505B50E7D3998FC8C8B77F0@phx.gbl>
Content-Type: text/plain; charset=us-ascii
Mohammed Mustafa wrote:
>
>
> Many thanks waleed & John
>
> actually i have 4 different variables and i used your method as a key to
> deal with the rest of them
> below is the syntax that i used , i'd like to know your opinion about it
>
> RECODE Q1a (1 thru 5=1) (6 thru 99=0) (ELSE=SYSMIS) INTO X1.
> RECODE Q1b (1 thru 5=1) (6 thru 99=0) (ELSE=SYSMIS) INTO X2.
>
> RECODE Q2a (1 thru 5=1) (6 thru 99=0) (ELSE=SYSMIS) INTO X3.
> RECODE Q18 (1=1) (2 thru 99=0) (ELSE=SYSMIS) INTO X4.
>
> IF (((X1=1) OR (X2=1) OR (X3=1)) AND (X4=0)) X5=1.
> IF ((X1=0) AND (X2=0) AND (X3=0) AND (X4=1)) X5=2.
> IF (((X1=1) OR (X2=1) OR (X3=1)) AND (X4=1)) X5=3.
> IF ((X1=0) AND (X2=0) AND (X3=0) AND (X4=0)) X5=0.
> EXECUTE.
>
> the results came exactlly as i needed but is there an easier way to do
> this or i just did it right ?
>
> Thanks & best regards,
> Mohammed
>
Does this do what you want?
RECODE Q1a Q1b Q2a (1 thru 5=1) (6 thru 99=0) (ELSE=SYSMIS) INTO X1 X2 X3.
RECODE Q18 (1=1) (2 thru 99=0) (ELSE=SYSMIS) INTO X4.
IF ANY(1,X1,X2,X3) AND (X4=0)) X5=1.
IF ((X1=0) AND (X2=0) AND (X3=0) AND (X4=1)) X5=2.
IF ANY(1,X1,X2,X3) AND (X4=1)) X5=3.
IF ((X1=0) AND (X2=0) AND (X3=0) AND (X4=0)) X5=0.
EXECUTE.
-----
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."
NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Compute-generate-a-new-variable-tp2842066p2848223.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD