|
Hey all,
I was looking through some syntax that is used to code for a variable
(1=yes, 2=No) based on whether a certain value appears in any one of 25
variables. Presently the code looks like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compute newvar = 0.
if (bd1 >=200) & (bd1 <=299) newvar = 1.
if (bd2 >=200) & (bd2 <=299) newvar = 1.
if (bd3 >=200) & (bd3 <=299) newvar = 1.
.
.
.
if (bd24 >=200) & (bd24 <=299) newvar = 1.
if (bd25 >=200) & (bd25 <=299) newvar = 1.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Needless to say this is extremely cumbersome. Since I was modifying the
syntax file for some other analysis, I thought I might as well streamline
this part a bit too. What I came up with was:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPUTE newvar=0.
DO REPEAT a=bd1 TO bd25.
DO IF (a>=200) & (a <=299).
COMPUTE newvar=1.
END IF.
END REPEAT.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This little bit of code works fine. I wanted to know if there is some
other way of doing the same thing - a simpler, easier, neater way than the
DO REPEAT statements? I know that the ANY(varname, value1, value2,
value3) code looks for different values within the same variable, but is
there a way of looking at the same value (or a set of values) in different
variables?
Thanks.
- Steve
=====================
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
|