Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting string values with the wrong decimal separator into numric values

2,115 views
Skip to first unread message

Jacob

unread,
Feb 23, 2010, 4:41:32 AM2/23/10
to
Hi,

I have a large dataset with blood sample results as string variables
due to a possible outcome of <0,01 (not my choice - the lab send me
the results in an excel spreadsheet formatted this way)
.
I've recoded the variable (REPLY.1) into a new one (REPLY.1N) where
<0,01 => 0 and all other values are the kept. This to get rid of the
"<".

However, when I use:

recode REPLY.1 (convert) into REPLY.1N.
execute.

to get numeric values only the 0's (zeroes) are kept.
All other values (eg. 1,24; 5,10; 0,32 etc.) are listed as missing.

I suspect it is because the decimal separator used in the original
string variable (REPLY.1) is a comma.

How can I convert REPLY.1 into a numeric variable without loosing all
the important results?


Thanks in advance

Jacob Sorensen

Bruce Weaver

unread,
Feb 23, 2010, 7:20:50 AM2/23/10
to


Use the REPLACE function to replace all of the commas in REPLY.1 with
periods before converting it to a numeric variable.

compute REPLY.1 = replace(REPLY.1,",",.").


recode REPLY.1 (convert) into REPLY.1N.
execute.

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

WimN

unread,
Feb 23, 2010, 12:52:47 PM2/23/10
to
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home

> "When all else fails, RTFM."

My version of SPSS (13.0) doesn't seem to have a REPLACE function, but
if I were you, I'd do the replacement (of , into .) in Excel, before
importing the file into SPSS.
Another option is to - temporarily - change the default decimal
separator in your operating system. If it's Windows, you do that in
Control panel > Regional and language options.

Ben Pfaff

unread,
Feb 23, 2010, 1:12:02 PM2/23/10
to
WimN <wim...@gmail.com> writes:

> Another option is to - temporarily - change the default decimal
> separator in your operating system. If it's Windows, you do that in
> Control panel > Regional and language options.

Or just:
SET DECIMAL=COMMA.
...recode commands...
SET DECIMAL=DOT.
--
Ben Pfaff
http://benpfaff.org

Jacob

unread,
Feb 24, 2010, 4:34:04 AM2/24/10
to
Thank you all very much for your help.


Jacob

0 new messages