Date: Sat, 29 Nov 2008 14:40:51 -0500
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Art Kendall <Art@DrKendall.org>
Organization: Social Research Consultants
Subject: Re: case selection
Content-type: text/plain; charset=UTF-8; format=flowed
The careful distinction of 'and' vs 'or' is fundamental in computer
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
Nancy Darling wrote:
> Johnny Amora wrote:
>> 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 .
> 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
For a list of commands to manage subscriptions, send the command