SPSS is everywere

(Source: Flickr)
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.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « May | Sep » | |||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||