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 16:37:47 -0600
Reply-To:   ViAnn Beadle <vab88011@gmail.com>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   ViAnn Beadle <vab88011@gmail.com>
Subject:   Re: DO IF statement loop
In-Reply-To:   <417.879-16556-1492853290-1215468552@seznam.cz>
Content-Type:   text/plain; charset="iso-8859-2"

Is the goal here to minimize the number of characters in the syntax file? If so, here's an semi-obscure way to do it. This assumes as in your cases that bd1 to bd25 are in file order.

Recode bd1 to b25 (200 thru 299=1)(else=0) into #newvar1 to #newvar25. Compute var1 = any(1, newvar1 to newvar25).

---Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Jerabek Jindrich Sent: Monday, July 07, 2008 4:09 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re:DO IF statement loop

Hi Steve,

Your DO REPEAT syntax is just perfect.

You might simplify it a little using Range (a,200,299) instead of IF (a>=200) & (a <=299)., but it is a small not important improvement.

regards Jindra

> ------------ Původní zpráva ------------ > Od: Steve <cheesehead.in.tx@GMAIL.COM> > Předmět: DO IF statement loop > Datum: 07.7.2008 22:17:19 > ---------------------------------------- > 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 > > >

===================== 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

===================== 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