FW: Converting Mixed String-Numeric Variables

View: New views
1 Messages — Rating Filter:   Alert me  

FW: Converting Mixed String-Numeric Variables

by ViAnn Beadle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm forwarding this to the list.

Here's a simple solution:

STRING newvar a2.
COMPUTE newvar = SUBSTR(oldvar,1,2).

This returns GG.
-----Original Message-----
From: Krinsky, Alan [mailto:KrinskyA@...]
Sent: Wednesday, July 02, 2008 8:13 AM
To: ViAnn Beadle
Subject: RE: Converting Mixed String-Numeric Variables

Old: GG4586712
New: GG
Alternate new: Gold


Alan D. Krinsky  PhD, MPH
Manager, Medical Management Interventions
UMass Memorial Health Care
Hahnemann Campus
281 Lincoln St.
Worcester, MA 01605
Phone: 508-334-5854
Fax: 508-793-6086
E-mail: krinskya@...

-----Original Message-----
From: ViAnn Beadle [mailto:vab88011@...]
Sent: Wednesday, July 02, 2008 10:04 AM
To: Krinsky, Alan; SPSSX-L@...
Subject: RE: Converting Mixed String-Numeric Variables

Provide an example of your existing variable(s) and your desired new
variable.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@...] On Behalf Of
Krinsky, Alan
Sent: Wednesday, July 02, 2008 7:36 AM
To: SPSSX-L@...
Subject: Converting Mixed String-Numeric Variables

I am having difficulty transforming or computing a new variable for
identification variables starting with 2 letters followed by several
numbers. I would prefer to keep the two letters for identification and
drop all of the numbers to the right of these, but every approach I try
seems to get blocked. If I use a command that treats the original
variable as a string, the error message suggests a numeric variable or
argument is missing, and if I treat the original variable as numeric
there is an error message in search of a string variable. So, I cannot
get something as simple as LTrim or RTrim to work. I tried first
converting the original variable into string or numeric (according to
the variable definitions, it is a string), but I am getting similar
error messages. Any ideas?


Alan D. Krinsky  PhD, MPH
Worcester, MA




The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, transmission, re-transmission, dissemination or
other use of, or taking of any action in reliance upon this information
by persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete the
material from any computer.

=======
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (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@... (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
LightInTheBox - Buy quality products at wholesale price