Recode and wildcards

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Recode and wildcards

Stefan Keydel
Hello,

Is it possible to use wildcards when recoding variables? For example, if
I had a variable that included the following values:

Bluebird
Ladybird
Birdwatcher
Butterfly
Elm

and I wanted to recode any values that included 'bird' into a new value
'BIRD', can I do this with the Recode transformation?

Apologies if this has been addressed already on this list.


Regards,

Stefan
Reply | Threaded
Open this post in threaded view
|

Re: Recode and wildcards

Raynald Levesque
Hi

Wildcard cannot be used with RECODE.

The following 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.

You could use a DO REPEAT if you have many such recode to do.

Regards

Raynald Levesque [hidden email]
Visit my SPSS site: http://www.spsstools.net



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Stefan Keydel
Sent: July 7, 2006 5:43 PM
To: [hidden email]
Subject: Recode and wildcards

Hello,

Is it possible to use wildcards when recoding variables? For example, if I
had a variable that included the following values:

Bluebird
Ladybird
Birdwatcher
Butterfly
Elm

and I wanted to recode any values that included 'bird' into a new value
'BIRD', can I do this with the Recode transformation?

Apologies if this has been addressed already on this list.


Regards,

Stefan