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:48:28 -0500
Reply-To:   Richard Ristow <wrristow@mindspring.com>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Richard Ristow <wrristow@mindspring.com>
Subject:   Re: case selection
Comments:   To: Nancy Darling <nancy.darling@oberlin.edu>
Comments:   cc: Lewis <karen.watkinslewis@ATT.NET>
In-Reply-To:   <493170A9.5010805@oberlin.edu>
Content-Type:   text/plain; charset="us-ascii"; format=flowed

A note on SPSS syntax: At 11:41 AM 11/29/2008, Nancy Darling wrote,

>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). > >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.

Right. But that overlooks RECODE, one of the best-designed features of SPSS, which gives shorter and (I think) clearer syntax:

RECODE id ( 5, 8, 10, 27, 105 = 1) (1005, 1008, 1010, 1027, 1105 = 1) (ELSE = 0) INTO tempid.

>select if tempid=1.

(There are many variations to RECODE syntax. A lot of people would write

RECODE id ( 5, 8, 10, 27, 105, 1005, 1008, 1010, 1027, 1105 = 1) (ELSE = 0) INTO tempid.

and some would go the other way and write,

RECODE id ( 5 = 1) ( 8 = 1) ( 10 = 1) ( 27 = 1) ( 105 = 1) (1005 = 1) (1008 = 1) (1010 = 1) (1027 = 1) (1105 = 1) INTO tempid.

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