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 (November 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 29 Nov 2008 14:40:51 -0500
Reply-To:     Art@DrKendall.org
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Art Kendall <Art@DrKendall.org>
Organization: Social Research Consultants
Subject:      Re: case selection
In-Reply-To:  <493170A9.5010805@oberlin.edu>
Content-type: text/plain; charset=UTF-8; format=flowed

The careful distinction of 'and' vs 'or' is fundamental in computer languages. For many people the use of the traditional operators helps them because they are easier to perceive than the symbolic ones. or, and, lt, le, ge, gt, ne etc are easier for many people to see than the symbols & | < <= >= > <> etc. & is often used to indicate concatenation of strings which gives it two meanings depending on context..

It is extremely difficult for many people to read syntax that uses the same same symbol two ways depending on context. When programs started allowing = to mean a logic equal operator as opposed to an assignment operator many beginners find it difficult figure which context is meant.

As a rule it enhances readability to use = solely as an assignment operator and to use eq for the logical operator. This is often beneficial even when the symbolic operators are use for the other logical meanings.

Art Kendall

Nancy Darling wrote: > Johnny Amora wrote: >> Karen, >> >> Suppose you select three cases with ID numbers 5, 8 and 10 where id >> is the variable name. Just type the following on the "Select Cases: >> If" dialog box: >> >> id=5 & id=8 & id=10 >> >> In that command, an = sign was used followed by &. You can use >> symbols < , < or ~ depending on what you want. >> > > If you use an '&' sign, it won't select anything, because no case has an > id number equal to all three values. You want an 'or', don't you? > > select if id=5 or id=8 or id=10. > > In older versions of SPSS, I have found if you have too many 'or' and > 'and' statements it will eventually stop selecting correctly (I'm > recalling 5, but it's been a long time). > > If you have a lot of random ids you want to select, you can compute a > temporary variable that is set to 0 and becomes 1 if it matches the id. > Then select for the temporary variable (similar to the syntax in the > original post). The advantage of doing it that way is you can have an > unlimited number of if statements, so could potentially choose 100's of > individual ids if you needed to. > > compute tempid=0. > if id=5 or id=8 or id=10 or id=27 or id=105 tempid=1. > if id=1005 or id=1008 or id=1010 or id=1027 or id=1105 tempid=1. > select if tempid=1. > > >> >> Try also this sample syntax: >> >> USE ALL. >> COMPUTE filter_$=(id=5 & id=8 & id = 10). >> VARIABLE LABEL filter_$ 'id=5 & id=8 & id = 10 (FILTER)'. >> VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. >> FORMAT filter_$ (f1.0). >> FILTER BY filter_$. >> EXECUTE . >> >> Cheers, >> Johhny >> >> > > ===================== > 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