Date: Thu, 10 Jan 2008 16:49:55 -0600
Reply-To: "Norton, John" <jnorton@spss.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Norton, John" <jnorton@spss.com>
Subject: Re: select cases from part of idnum variable
In-Reply-To: A<47864C0A.7E13.0074.3@loyola.edu>
Content-Type: text/plain; charset="us-ascii"
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).
I hope this helps. If I can offer any further assistance or clarification, please do not hesitate to ask.
Good Luck,
John Norton
SPSS Inc.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Martin Sherman
Sent: Thursday, January 10, 2008 3:47 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: select cases from part of idnum variable
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,
Martin F. Sherman, Ph.D.
Professor of Psychology
Director of Masters Education: Thesis Track
Loyola College
Psychology Department
222 B Beatty Hall
4501 North Charles Street
Baltimore, MD 21210
410 617-2417 (office)
410 617-5341 (fax)
msherman@loyola.edu
=====================
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
|