Combining two variables, but not adding them

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

kmmille3
Posts: 9
Joined: Wed Mar 07, 2012 5:44 am

Combining two variables, but not adding them

Postby kmmille3 » Wed Mar 07, 2012 6:02 am

Hi,

I'm new to the site and SPSS. I hope you all can help me.

I have a dataset with two variables that I want to combine. Race (values 1-4) and Hispanic (values 5-6). I don't know how to combine these two variables. I am not trying to add the variables together as that would give me categories outside of 6. How do I combine the two variables?

I think my syntax would look something like this:

IF oldracevariable =1 and Hispanic= 0 newracevariable=1.
IF oldracevariable =2 and Hispanic=0 newracevariable=2.
...
IF oldracevariable=6 and Hispanic=0 newracevariable=6.

Is this correct?
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Combining two variables, but not adding them

Postby GerineL » Wed Mar 07, 2012 9:39 am

almost, try this:
kmmille3 wrote:
if (oldracevariable =1 & Hispanic= 0 ) newracevariable=1.
IF (oldracevariable =2 & Hispanic=0) newracevariable=2.
...
IF (oldracevariable=6 & Hispanic=0 ) newracevariable=6.
Execute.
kmmille3
Posts: 9
Joined: Wed Mar 07, 2012 5:44 am

Re: Combining two variables, but not adding them

Postby kmmille3 » Wed Mar 07, 2012 3:38 pm

Is there an initial step before I start coding the variables?

I used the syntax format you suggested, and when I ran the syntax, my new variable was created, but there were no were no values in the new variable.

I appreciate your help!
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Combining two variables, but not adding them

Postby GerineL » Thu Mar 08, 2012 8:27 am

do you get an error message?

Can you tell me what type your original varaibles were?
kmmille3
Posts: 9
Joined: Wed Mar 07, 2012 5:44 am

Re: Combining two variables, but not adding them

Postby kmmille3 » Thu Mar 08, 2012 9:30 pm

No, I don't get an error message. The syntax runs, but no values are in the variable after the syntax runs.

My original variables are numeric and they are scaled.
The original dataset has race listed as white, black, native american, asian, and multi race.
I then recoded the variable (RaceRC) so that race is listed as 1-4.

The original dataset has hispanics listed separately as a dummy variable. (Hispanic =1 Non Hispanic = 2).
I recoded this variable (Hisp) as Hispanic = 5 and Non Hispanic =6.

Then I used the syntax
IF (RaceRC=1 & Hisp=0) NewRace=1.
IF (RaceRC=2 & Hisp=0) NewRace=2.
IF (RaceRC=3 & Hisp=0) NewRace=3.
IF (RaceRC=4 & Hisp=0) NewRace=4.
IF (RaceRC=5 & Hisp=0) NewRace=5.
IF (RaceRC=6 & Hisp=0) NewRace=6.
Execute.

SPSS lets me run it, and it creates a new variable, but no values are in the variable. Does this make sense?
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Combining two variables, but not adding them

Postby GerineL » Fri Mar 09, 2012 8:28 am

well, if your hispanic variable only contains 5 &6, no cases match your criterium of hispanic = 0.
kmmille3
Posts: 9
Joined: Wed Mar 07, 2012 5:44 am

Re: Combining two variables, but not adding them

Postby kmmille3 » Fri Mar 09, 2012 6:53 pm

Thank you SO much!!!

I finally got it to work :)

Who is online

Users browsing this forum: No registered users and 2 guests

cron