Date: Thu, 29 Apr 2004 16:06:26 -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: IF THEN recode
Content-Type: text/plain; charset="us-ascii"
Julie:
Your syntax for Q1 works for me, on the sample data below-- are ABC_1 TO
ABC_10 string variables? Are there any error messages?
Here is syntax using DO REPEAT to do what you want for both questions (I
assume numeric variables):
** sample data.
DATA LIST FREE /ABC (f8.0) ABC_1 TO ABC_10 (10F8.0).
BEGIN DATA
1 1 1 1 1 1 1 9 9 9 9
0 1 3 5 . . 9 9 9 9 9
END DATA.
DO REPEAT x = ABC_1 TO ABC_10.
IF ABC EQ 1 x EQ 88.
IF ABC EQ 0 AND SYSMIS(x) x = 0.
END REPEAT.
EXECUTE.
jim
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of
Rao, Julie M.
Sent: Thursday, April 29, 2004 3:49 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Re: IF THEN recode
Hi Kurt,
For Q1, I'm sure there are more sophisticated ways of doing it, but this
will work as long as variable ABC is either 1 or 0. Q2 is taken care of
in
with the else if. If variables ABC_1 to ABC_10 do not exist before this
DO
IF, it may fail.
DO IF ABC = 1.
COMPUTE ABC_1 = 88.
COMPUTE ABC_2 = 88.
COMPUTE ABC_3 = 88.
COMPUTE ABC_4 = 88.
COMPUTE ABC_5 = 88.
COMPUTE ABC_6 = 88.
COMPUTE ABC_7 = 88.
COMPUTE ABC_8 = 88.
COMPUTE ABC_9 = 88.
COMPUTE ABC_10 = 88.
ELSE IF ABC = 0.
RECODE ABC_1 TO ABC_10
(MISSING = 0).
END IF.
If ABC is missing/blank, <> 1 or <> 0, then the case will be ignored and
the
values of ABC_1 to ABC_10 will not be changed/calculated. HTH.
Julie
-----Original Message-----
From: Heisler, Kurt W [mailto:HeisleKW@chkd.com]
Sent: Thursday, April 29, 2004 4:30 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: IF THEN recode
I'm struggling with what should be some basic syntax.
QUESTION 1:
**********
I need to impute some values into existing variables based on the value
in
another variable. For example:
If variable ABC has a value of 1, I would like ABC_1, ABC_2, ABC_3 .
. .
ABC_10 (they're all in order) to have a value of 88.
My current syntax isn't doing it:
DO IF (ABC = 1).
RECODE ABC_1 to ABC_10 (ELSE=88).
END IF.
EXECUTE .
QUESTION 2:
**********
If variable ABC has a value of 0, I would like ABC_1, ABC_2, ABC_3 .
. .
ABC_10 to have a value of 0 ONLY IF the cell is blank.
An example case might look like this:
ID ABC ABC_1 ABC_2 ABC_3 ABC_4 . . . ABC_10
-------------------------------------------------------
003 0 1 1 1
In this example, ABC_2 & ABC_3 need to be imputed with a value of 0.
###
Thanks.
Kurt
CHKDHS Disclaimer
The information contained in this e-mail message, including any
attachment(s), is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized
review,
use, disclosure or distribution is prohibited and may result in Legal
action. If you are not the intended recipient, and have received this
communication in error, please contact the sender by reply e-mail and
destroy all copies of the original message.