recode a variable case to subcategories (keep others)

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

drdunkel
Posts: 5
Joined: Thu Jul 24, 2014 5:31 pm

recode a variable case to subcategories (keep others)

Postby drdunkel » Thu Jul 24, 2014 5:49 pm

Hi all,
I don't know if my question should be in this or beginner section, but anyway:

how could I recode some of the variable values, while keeping other old values?
My variable is numeric categorical, and I want to recode A variable values "5" to subcategories depending on variable B (also numeric categorical) - but if A has any other value than 5, I want to keep this value.

I.e. when A=5 (Party) and B= 3 (Green) --> A_NEW=100 (Party Green). Or: when A=3 --> A_NEW=3 (oldlabel). So whenever A has value 5 the new variable should combine with the equivalent value of B-variable (and Label to be Label A+label B, or just Label A). Whenever A has other than 5 as value, the newvariable would keep this old value.

I don't want to recode the old variable directly, in case of mistakes (although this would be the easiest - could I just copypaste all the cases in current order under new variable or is there a danger of Messing up data?)
As i have lots of different categories (200 in variable A and 50 in variable B), this would take forever by the Basic "compute" + "if" function I know...

thanks!
RubenGeert
Posts: 100
Joined: Mon May 19, 2014 6:06 am

Re: recode a variable case to subcategories (keep others)

Postby RubenGeert » Thu Jul 24, 2014 6:28 pm

First read this: http://www.spss-tutorials.com/recode/ It's covered in the third example.

However, consider cloning your variable and RECODE it into the same variable. The reason is that new variables don't have any variable/value labels or missing values and you probably don't want to specify all of these manually.

A nice tool for cloning variables is found here: http://www.spss-tutorials.com/clone-variables/

Kind regards,

Ruben Geert van den Berg
www.spss-tutorials.com
drdunkel
Posts: 5
Joined: Thu Jul 24, 2014 5:31 pm

Re: recode a variable case to subcategories (keep others)

Postby drdunkel » Thu Jul 24, 2014 6:39 pm

thanks a lot i will look into those!

Who is online

Users browsing this forum: No registered users and 3 guests

cron