Recoding with a syntax
August 17th, 2006 mark
This week we got a question from Timo.
Is it possible to use syntax when recoding variables? For example, if I
had a variable that included the following values:
Ladybird
Bluebird
Elm
Butterfly
and I wanted to recode any values that included ‘bird’ into a new value
‘bird’, can I do this with the Recode transformation?
To solve to problem the following syntax is an option:
DATA LIST LIST /var1(A15).
BEGIN DATA
Bluebird
Ladybird
Birdwatcher
Butterfly
Elm
END DATA.
STRING newVar(A15).
DO IF INDEX(UPCASE(var1),”BIRD”) > 0 .
- COMPUTE newVar=”BIRD”.
END IF.
EXECUTE.
Do you also need an answer to your SPSS question, submit your question here.
Entry Filed under: 5. Coding SPSS Syntax, Questions and answers
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed