Sent: Wednesday, January 03, 2001 9:24
PM
Subject: Re: CONVERTING STRING TO NUMERIC
VARIABLES
First, you can recode string values into numeric
values.
Technically, CIP codes (as used by NCES) are
string values; although it is possible to construct them as numeric--I don't
see a reason to. However, CIP codes are formatted nn.nnnn, since you
are recoding into 4-digit CIPs it appears that you are using the
first four digits without a decimal. Be careful with an implied decimal
because if you don't pad zeros correctly you'll have a problem. (I'm
reading that 'XEA' and 'XEF' are education courses and 'PHE' is a parks
management course. Tell me if I'm wrong.) Also, adding an explicit
decimal differentiates CIP codes (nn.nnnn) from HEGIS codes (nnnn.nn) so there
is no mistaking them.
If you didn't create the CIP variable with enough
space, the "expanded" codes wouldn't fit and you could have a problem.
This could be what happened when you added additional courses to be recoded to
the list (the CIP codes didn't fit). Assuming that the variable
"nucourse" is in the file sdmsu99.sav, try the following:
GET FILE=C:\CCAR99\SDMSU99.sav'.
EXECUTE.
NUMERIC cipcrs (N7).
RECODE nucourse('XEA'=13.0400)
('PHE'=31.0300)
('XEF'=13.1200)
into
cipcrs.
VARIABLE LABELS cipcrs 'cip
course'.
EXECUTE.
The only change is that I defined the variable called
"cipcrs" as N7 which will retain leading zeros where appropriate and will
accept four decimal places with an explicit decimal, I also padded the
trailing zeros. (The N format is handy if you have a "numeric"
variable with leading zeros and want to display them--it is numeric for
mathematical purposes.) If this doesn't work, let me know.
FWIW, your second example won't work for two
reasons. "Convert" is only used to turn string representations of
numeric values into "true" numeric values. For example, a string '1'
becomes a numeric 1. And, secondly, I know your original file doesn't
have a scratch variable named #nucourse, a) it's too long and b) scratch
variables can't be saved--hence their name.
"Those who cast the votes decide nothing.
Those who count the votes
decide everything."
-Joseph Stalin
----- Original Message -----
Newsgroups: bit.listserv.spssx-l
Sent: Wednesday, January 03, 2001 5:42
PM
Subject: CONVERTING STRING TO NUMERIC
VARIABLES
I'm converting course names that are string
variables into CIP codes that are numeric variables. Initially, the
Recode function worked perfectly. Then I expanded the list of
recodes. Once this list was finished I got the following message: "A
string variable cannot be recoded to a numeric value. Consider the
CONVERT or INTO options. This command not executed." I checked
the an SPSS syntax manual, release 6.0 and revised the recode
statement. It's still not working.
Here is a truncated version of the
script:
Get
File=C:\CCAR99\SDMSU99.sav'.
EXECUTE
RECODE
NUCOURSE('XEA'=1304) ('PHE'=3103) ('XEF'=1312)
into cipcrs.
VARIABLE LABELS cipcrs'cip
course'.
EXECUTE.
After the error message, I revised the
script:
Get
File=C:\CCAR99\SDMSU99.sav'.
EXECUTE
RECODE
#NUCOURSE (CONVERT)
('XEA'=1304) ('PHE'=3103) ('XEF'=1312) into
cipcrs.
VARIABLE LABELS cipcrs'cip
course'.
EXECUTE.
This didn't work either. SPSS didn't recognize "#NUCOURSE." What
did I do wrong?