Reputation: 11
I have a dataset with 1500+ codes for medical treatments (Verrichtingcode). They are coded such as 337409A, 339830E or 336690. This is a string variable. I want to use the syntax to change those into, let's say: laparoscopic abdominal surgery. I have the translation for all these codes standing by.
If I use the syntax:
VALUE LABELS
Verrichtingcode
339985B 'Sedation'.
EXECUTE.
What comes out is: 339985 = "B 'Sedation'"
Which doesn't work.
I then tried to Recode >
RECODE Verrichtingcode
(339985B= AA339985BBB).
EXECUTE.
RECODE Verrichtingcode
(339985B= AA339985BBB).
EXECUTE.
This works fine, until you get to a code with an E at the end.
RECODE Verrichtingcode
(336070D= AA336070DBB)
(333698E= AA333698EBB).
EXECUTE.
RECODE Verrichtingcode
(336070D= AA336070DBB)
(333698E= AA333698EBB).
EXECUTE.
What I get is:
>Warning # 203 in column 2. Text: 333698E
>An 'E', beginning the exponent portion of a number, was not followed by any
>digits.
>The symbol will be treated as an invalid special character.
>Error # 4654 in column 2. Text: 339993
>The RECODE command attempts to test a string variable for having a numeric
>value. Note that LOWEST, HIGHEST, and SYSMIS are considered to be numeric
>values.
>Execution of this command stops.
EXECUTE.
I could off course do it all by hand in the Variable view, but with 1500+ procedures it's gonna take some time ;)
If any of you would be so kind to help me, It would be really appreciated. If you need more info, I would be happy to deliver.
Upvotes: 1
Views: 1909
Reputation: 5417
With 1500 codes, you really don't want to do this with IF or RECODE. Assigning value labels is the usual way of dealing with this. If you actually need the variable values to be the identifying strings, a table lookup would be vastly better. MATCH FILES with the TABLE subcommand can handle this. You would create a dataset with the keys and labels, sort it and the regular data, and then use MATCH with TABLE.
Upvotes: 2
Reputation: 11350
Since this is a string variable you need to use quotation marks around the values in both commands you used:
VALUE LABELS Verrichtingcode
'339985B' 'Sedation'.
or
RECODE Verrichtingcode ('339985B'= 'AA339985BBB').
EXECUTE.
Upvotes: 1