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