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 (January 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 11 Jan 2008 11:34:47 -0500
Reply-To:     Catherine Kubitschek <Catherine.A.Kubitschek.2@nd.edu>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Catherine Kubitschek <Catherine.A.Kubitschek.2@nd.edu>
Subject:      Re: select cases from part of idnum variable
Comments: To: Martin Sherman <MSherman@loyola.edu>
In-Reply-To:  <478683BB.7E13.0074.3@loyola.edu>
Content-Type: text/plain; charset="us-ascii"; format=flowed

Martin, thanks for the information.

You've gotten a couple of good answers already. Art Kendall's solution works because your data is a standard format & width.

At 1/11/2008 08:49 AM, Art Kendall wrote: >compute newidnum= trunc (idnum/10000). >recode newidnum(101 thru 105, 107, 114, 117,118=1)(else=0) into mygroup. > >select if mygroup eq 1). > OR >filter by mygroup.

John Norton's solution would work regardless of exactly what your data looked like:

At 1/10/2008 05:49 PM, Norton, John wrote: >Hi Dr. Sherman, > >I think one way to approach this is to treat the source as a string >variable, and then convert the extracted values back to numbers within the >ANY() function. The following example takes this approach, and therefore >allows me to use several string functions, evaluate for the selection >criteria, and then create a binary flag variable on which I can filter or >execute a SELECT IF command. > >COMPUTE flag = > ANY((NUMBER(SUBSTR(LTRIM(RTRIM(STRING(id,F8))),1,3),F8)), > 101,102,103,104,105,107,114,117,118).

At 1/10/2008 08:44 PM, Martin Sherman wrote: >Catherine: The format is F7.0. The lowest values are below and >1010002 >1010007 >1010009 >1010016 > ..... >..... >1181319 Here is the highest value. My concern is only with the first >three digits. > >thanks, > ><snip> > >At 1/10/2008 04:47 PM, Martin Sherman wrote: > >Dear list: I have a large data set with a variable called IDNUM which has > >8 digits. I want to select those cases that start with 101, 102, 103, > >104, 105, 107, 114, 117, or 118. I don't care what numbers come after the > >first three. I check Raynald Levesque's site and could not find a syntax > >program for selecting cases based on the first three values of a numerical > >variable. Suggestions appreciated. thanks,

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