LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 7 Jul 2008 13:25:25 -0400
Reply-To:   Steve <cheesehead.in.tx@GMAIL.COM>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Steve <cheesehead.in.tx@GMAIL.COM>
Subject:   DO IF statement loop

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


Back to: Top of message | Previous page | Main SPSSX-L page