Recoding with a syntax

August 17th, 2006

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


Calendar

August 2006
M T W T F S S
« May   Sep »
 123456
78910111213
14151617181920
21222324252627
28293031  

Most Recent Posts