compute new race variable from 2 fields

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

compute new race variable from 2 fields

parisec
 
Hi all,
 
I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.
 
Field 1=Race1:    makes people select from only 1 of  9 different races. Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)
 
I created a new variable called allrace. Here is what i want to do:
 
If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic
If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1
If Race_Hispanic =no, Allrace =Race1
 
My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.
 
Thanks for any syntax of wisdom.
 
Carol
 
 
 
 
 
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

Joseph Willey
Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races. Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic
If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1
If Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

statisticsdoc
In reply to this post by parisec

Carol,

 

It looks like this if I can assume that white means Race1 eq 1  , and that you want to create two groups in allrace (1 = Non Hispanic White;  10 = Hispanic White)  .

 

If (   Race1 eq 1 ) and (Race_Hispanic eq 1 )  allrace = 10   .

If (   Race1 eq 1 ) and (Race_Hispanic eq 0 )  allrace = 1   .

If (   Race1 gt 1 )   allrace =  Race1  .

 

It does not appear that you are changing the coding of race for non-white subjects based on whether or not they are Hispanic.

 

Best,

 

Stephen Brand

 

www.StatisticsDoc.com

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Thursday, January 05, 2012 6:54 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

 

 

Hi all,

 

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

 

Field 1=Race1:    makes people select from only 1 of  9 different races. Hispanic is not an option.

Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

 

I created a new variable called allrace. Here is what i want to do:

 

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic

If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1

If Race_Hispanic =no, Allrace =Race1

 

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

 

Thanks for any syntax of wisdom.

 

Carol

 

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

parisec
In reply to this post by Joseph Willey
here you go!

the end result gives me the correct number of hispanics and whites. but then it gives me the number of people of other races who stated that they are hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races. Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

statisticsdoc
Carol,

What is race_comb and how was it computed?

Best,

Steve

www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

here you go!

the end result gives me the correct number of hispanics and whites. but then
it gives me the number of people of other races who stated that they are
hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4
'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9
'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise,
Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for
race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic
(1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any
other race except for white and Race_hispanic =yes, then Allrace=Race1 If
Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I
am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

parisec
Ahh...my error in my posting. race_comb should be RACE1. for this post, i change the name race_comb to RACE1 for simplicity.

this is the corrected syntax:


compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race1.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.

-----Original Message-----
From: StatisticsDoc [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:32 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,

What is race_comb and how was it computed?

Best,

Steve

www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

here you go!

the end result gives me the correct number of hispanics and whites. but then it gives me the number of people of other races who stated that they are hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

Joseph Willey
Even still, all of the people who are not white and not hispanic are sysmis.

Change    if (race1 ge 1 and race_hispanic=1) allrace=race_comb.

to --> IF (race1 GE 1) allrace=race1.

Joe

________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:37 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

Ahh...my error in my posting. race_comb should be RACE1. for this post, i change the name race_comb to RACE1 for simplicity.

this is the corrected syntax:


compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race1.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.

-----Original Message-----
From: StatisticsDoc [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:32 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,

What is race_comb and how was it computed?

Best,

Steve

www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

here you go!

the end result gives me the correct number of hispanics and whites. but then it gives me the number of people of other races who stated that they are hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

statisticsdoc
In reply to this post by parisec
Carol,

What appears to be missing is the line:


if (race1 ge 1 and race_hispanic=0) allrace=race1.

Without this line, all of the non-white non-hispanics are missing on
allrace.

Once you add this line, it becomes clear that the two statements:

if (race1 ge 1 and race_hispanic=1) allrace=race1.
if (race1 ge 1 and race_hispanic=0) allrace=race1.

Can be simplified to this one statement:

if (race1 ge 1) allrace=race1.

With the added advantage of computing allrace for non-white cases who had
missing data on race_hispanic .

Best,

Steve


www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Thursday, January 05, 2012 7:38 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

Ahh...my error in my posting. race_comb should be RACE1. for this post, i
change the name race_comb to RACE1 for simplicity.

this is the corrected syntax:


compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race1.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4
'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9
'philipino' 10 'korean' 99 'other-unknown'.

-----Original Message-----
From: StatisticsDoc [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:32 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,

What is race_comb and how was it computed?

Best,

Steve

www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

here you go!

the end result gives me the correct number of hispanics and whites. but then
it gives me the number of people of other races who stated that they are
hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4
'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9
'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise,
Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for
race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic
(1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any
other race except for white and Race_hispanic =yes, then Allrace=Race1 If
Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I
am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

parisec
In reply to this post by Joseph Willey
This works and  computes the correct number of hispanics and whites but it counts people who are state that they are any other race and hispanic twice.

For example:

for Race1 = Black has  n=12317

using crosstabs, i learned that 235 people who are black, also checked Yes for Race_Hispanic.

allrace computes black as 12317+235 = 12552

what i need is to have those 235 people not be included in the allrace field.

make sense?








-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:46 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Even still, all of the people who are not white and not hispanic are sysmis.

Change    if (race1 ge 1 and race_hispanic=1) allrace=race_comb.

to --> IF (race1 GE 1) allrace=race1.

Joe

________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:37 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

Ahh...my error in my posting. race_comb should be RACE1. for this post, i change the name race_comb to RACE1 for simplicity.

this is the corrected syntax:


compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race1.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.

-----Original Message-----
From: StatisticsDoc [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:32 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,

What is race_comb and how was it computed?

Best,

Steve

www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

here you go!

the end result gives me the correct number of hispanics and whites. but then it gives me the number of people of other races who stated that they are hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

Joseph Willey
Not what you originally said "If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1"

Think through it. Do your own work.

________________________________________
From: Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:54 PM
To: Joseph Willey; [hidden email]
Subject: RE: compute new race variable from 2 fields

This works and  computes the correct number of hispanics and whites but it counts people who are state that they are any other race and hispanic twice.

For example:

for Race1 = Black has  n=12317

using crosstabs, i learned that 235 people who are black, also checked Yes for Race_Hispanic.

allrace computes black as 12317+235 = 12552

what i need is to have those 235 people not be included in the allrace field.

make sense?








-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:46 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Even still, all of the people who are not white and not hispanic are sysmis.

Change    if (race1 ge 1 and race_hispanic=1) allrace=race_comb.

to --> IF (race1 GE 1) allrace=race1.

Joe

________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:37 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

Ahh...my error in my posting. race_comb should be RACE1. for this post, i change the name race_comb to RACE1 for simplicity.

this is the corrected syntax:


compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race1.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.

-----Original Message-----
From: StatisticsDoc [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:32 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,

What is race_comb and how was it computed?

Best,

Steve

www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

here you go!

the end result gives me the correct number of hispanics and whites. but then it gives me the number of people of other races who stated that they are hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

John F Hall
Have you thought about an intermediate step to combine the two variables.
You have 2 variables:

Race1 has codes 1 thru 9.
Race-hispanic has codes 0 and 1.
Looks as if you might have used 99 for missing.

I've often used the following trick.

compute allrace = race_hispanic*100 +  race1 .
freq allrace.
recode allrace (.........) [into allrace2]
val lab allrace2 .....

on the combinations to produce a tidier grouping.

If you called your variables v1 and v2 or q1 and q2 etc., you would save
yourself a lot of typing and avoid RSI!

John Hall

Email:    [hidden email]
Website: www.surveyresearch.weebly.com
Skype:    surveyresearcher1
Phone:    (+33) (0) 2.33.45.91.47




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Joseph Willey
Sent: 06 January 2012 01:58
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

Not what you originally said "If Race1=white and Race_Hispanic = Yes, then
Allrace=Hispanic If Race1=any other race except for white and Race_hispanic
=yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1"

Think through it. Do your own work.

________________________________________
From: Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:54 PM
To: Joseph Willey; [hidden email]
Subject: RE: compute new race variable from 2 fields

This works and  computes the correct number of hispanics and whites but it
counts people who are state that they are any other race and hispanic twice.

For example:

for Race1 = Black has  n=12317

using crosstabs, i learned that 235 people who are black, also checked Yes
for Race_Hispanic.

allrace computes black as 12317+235 = 12552

what i need is to have those 235 people not be included in the allrace
field.

make sense?








-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:46 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Even still, all of the people who are not white and not hispanic are sysmis.

Change    if (race1 ge 1 and race_hispanic=1) allrace=race_comb.

to --> IF (race1 GE 1) allrace=race1.

Joe

________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise,
Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:37 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

Ahh...my error in my posting. race_comb should be RACE1. for this post, i
change the name race_comb to RACE1 for simplicity.

this is the corrected syntax:


compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race1.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4
'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9
'philipino' 10 'korean' 99 'other-unknown'.

-----Original Message-----
From: StatisticsDoc [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:32 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,

What is race_comb and how was it computed?

Best,

Steve

www.StatisticsDoc.com


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

here you go!

the end result gives me the correct number of hispanics and whites. but then
it gives me the number of people of other races who stated that they are
hispanic.

compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4
'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9
'philipino' 10 'korean' 99 'other-unknown'.



-----Original Message-----
From: Joseph Willey [mailto:[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields

Carol,
It would help if you would post the actual syntax that you are using.

Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise,
Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
To: [hidden email]
Subject: compute new race variable from 2 fields

Hi all,

I suspect this is easy for one or more of you. I have 2 fields for
race/ethnicity in a file.

Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic
(1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any
other race except for white and Race_hispanic =yes, then Allrace=Race1 If
Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I
am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

DEBOER
In reply to this post by parisec
Hi,

test

string allrace(a15).
compute allrace=race1.
if (race1=white and race_his=yes) allrace=hispanic.
exe.
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

David Marso
Administrator
In reply to this post by parisec
Please post your current syntax and a crosstab of hispanic (columns) and race1 (rows).
Are there any missing values?
Given your recent syntax.
What happens to people who have value 2 on race1?  They get counted as Hispanic.
--

parisec wrote
Hi all,

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

Field 1=Race1:   makes people select from only 1 of  9 different races. Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

I created a new variable called allrace. Here is what i want to do:

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic
If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1
If Race_Hispanic =no, Allrace =Race1

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

Thanks for any syntax of wisdom.

Carol
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

parisec
Thanks.
 
 
The following syntax produces the table below
 
compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1) ) allrace=race1.
 
 
 
Allrace
  Frequency Percent Valid Percent Cumulative Percent
Valid .00 white 133067 66.0 66.0 66.0
1.00 black 12552 6.2 6.2 72.2
2.00 hispanic 31909 15.8 15.8 88.1
3.00 pacific islander 641 .3 .3 88.4
4.00 se asian 4977 2.5 2.5 90.8
5.00 indian continent 1242 .6 .6 91.5
6.00 american indian 327 .2 .2 91.6
7.00 chinese 4829 2.4 2.4 94.0
8.00 japanese 2251 1.1 1.1 95.1
9.00 philipino 6451 3.2 3.2 98.3
10.00 korean 1356 .7 .7 99.0
99.00 other-unknown 2004 1.0 1.0 100.0
Total 201606 100.0 100.0  
 
 
Here is the result of the crosstabs between the 2 variables
 
race_comb * hispanic Crosstabulation
Count
  race_hispanic Total
  .00 Non-hispanic 1.00 Hispanic  
race1 .00 white 133067 31909 164976
1.00 black 12317 235 12552
3.00 pacific islander 628 13 641
4.00 se asian 4960 17 4977
5.00 indian continent 1235 7 1242
6.00 american indian 309 18 327
7.00 chinese 4809 20 4829
8.00 japanese 2215 36 2251
9.00 philipino 6435 16 6451
10.00 korean 1346 10 1356
99.00 other-unknown 1751 253 2004
Total 169072 32534 201606
 
This is what I'd like the Allrace field to compute to. If they state that they are hispanic in addition to any other race, we want to pick up the 'any other race' versus the hispanic.
 
 
  AllRace
.00 white 133067
1.00 black 12317
2.00 hispanic 31909
3.00 pacific islander 628
4.00 se asian 4960
5.00 indian continent 1235
6.00 american indian 309
7.00 chinese 4809
8.00 japanese 2215
9.00 philipino 6435
10.00 korean 1346
99.00 other-unknown 1751
system missing 625
Total 201606
 
 
 
 
 
 
 
-----Original Message-----
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of David Marso
Sent: Friday, January 06, 2012 7:21 AM
Subject: Re: compute new race variable from 2 fields
 
Please post your current syntax and a crosstab of hispanic (columns) and
race1 (rows).
Are there any missing values?
Given your recent syntax.
What happens to people who have value 2 on race1?  They get counted as Hispanic.
--
 
 
parisec wrote
>
> Hi all,
>
> I suspect this is easy for one or more of you. I have 2 fields for
> race/ethnicity in a file.
>
> Field 1=Race1:   makes people select from only 1 of  9 different races.
> Hispanic is not an option.
> Field 2=Race_Hispanic:  makes people select whether or not they are
> hispanic (1=yes 0=no)
>
> I created a new variable called allrace. Here is what i want to do:
>
> If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If
> Race1=any other race except for white and Race_hispanic =yes, then
> Allrace=Race1
> If Race_Hispanic =no, Allrace =Race1
>
> My syntax and it runs just fine. But, i'm screwing something up
> because my I am ending up with the total number of people in my
> Race_Hispanic=Yes field.
>
> Thanks for any syntax of wisdom.
>
> Carol
>
 
 
--
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
 
=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
 
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

parisec
In reply to this post by John F Hall
 
 
Holy %^&* - this worked so fast and easy!
 
Since i posted the table of the semi-working syntax...Here is the result of:
 
compute allrace = race_hispanic*100 +  race1 .
freq allrace.
 
All i need to do now is recode 100 to be hispanic and ge 101 as "multiple".
 
Thanks a bunch for your help!
 
Carol
 
Allrace
  Frequency Percent Valid Percent Cumulative Percent
Valid .00 white 133067 66.0 66.0 66.0
1.00 black 12317 6.1 6.1 72.1
3.00 pacific islander 628 .3 .3 72.4
4.00 se asian 4960 2.5 2.5 74.9
5.00 indian continent 1235 .6 .6 75.5
6.00 american indian 309 .2 .2 75.7
7.00 chinese 4809 2.4 2.4 78.0
8.00 japanese 2215 1.1 1.1 79.1
9.00 philipino 6435 3.2 3.2 82.3
10.00 korean 1346 .7 .7 83.0
99.00 other-unknown 1751 .9 .9 83.9
100.00 31909 15.8 15.8 99.7
101.00 235 .1 .1 99.8
103.00 13 .0 .0 99.8
104.00 17 .0 .0 99.8
105.00 7 .0 .0 99.8
106.00 18 .0 .0 99.8
107.00 20 .0 .0 99.8
108.00 36 .0 .0 99.9
109.00 16 .0 .0 99.9
110.00 10 .0 .0 99.9
199.00 253 .1 .1 100.0
Total 201606 100.0 100.0  
 
 
 
 
 
 
 
 
 
-----Original Message-----
From: John F Hall [[hidden email]]
Sent: Thursday, January 05, 2012 10:56 PM
To: [hidden email]; Parise, Carol A.
Subject: RE: compute new race variable from 2 fields
 
Have you thought about an intermediate step to combine the two variables.
You have 2 variables:
 
Race1 has codes 1 thru 9.
Race-hispanic has codes 0 and 1.
Looks as if you might have used 99 for missing.
 
I've often used the following trick.
 
compute allrace = race_hispanic*100 +  race1 .
freq allrace.
recode allrace (.........) [into allrace2] val lab allrace2 .....
 
on the combinations to produce a tidier grouping.
 
If you called your variables v1 and v2 or q1 and q2 etc., you would save yourself a lot of typing and avoid RSI!
 
John Hall
 
Email:     [hidden email] 
Skype:     surveyresearcher1
Phone:    (+33) (0) 2.33.45.91.47
 
 
 
 
-----Original Message-----
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Joseph Willey
Sent: 06 January 2012 01:58
Subject: Re: compute new race variable from 2 fields
 
Not what you originally said "If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1"
 
Think through it. Do your own work.
 
________________________________________
From: Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:54 PM
To: Joseph Willey; [hidden email]
Subject: RE: compute new race variable from 2 fields
 
This works and  computes the correct number of hispanics and whites but it counts people who are state that they are any other race and hispanic twice.
 
For example:
 
for Race1 = Black has  n=12317
 
using crosstabs, i learned that 235 people who are black, also checked Yes for Race_Hispanic.
 
allrace computes black as 12317+235 = 12552
 
what i need is to have those 235 people not be included in the allrace field.
 
make sense?
 
 
 
 
 
 
 
 
-----Original Message-----
From: Joseph Willey [[hidden email]]
Sent: Thursday, January 05, 2012 4:46 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields
 
Even still, all of the people who are not white and not hispanic are sysmis.
 
Change    if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
 
to --> IF (race1 GE 1) allrace=race1.
 
Joe
 
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 7:37 PM
Subject: Re: compute new race variable from 2 fields
 
Ahh...my error in my posting. race_comb should be RACE1. for this post, i change the name race_comb to RACE1 for simplicity.
 
this is the corrected syntax:
 
 
compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race1.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.
 
-----Original Message-----
From: StatisticsDoc [[hidden email]]
Sent: Thursday, January 05, 2012 4:32 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields
 
Carol,
 
What is race_comb and how was it computed?
 
Best,
 
Steve
 
 
 
-----Original Message-----
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A.
Sent: Thursday, January 05, 2012 7:16 PM
Subject: Re: compute new race variable from 2 fields
 
here you go!
 
the end result gives me the correct number of hispanics and whites. but then it gives me the number of people of other races who stated that they are hispanic.
 
compute AllRace=$sysmis.
   if (race1=0 and race_hispanic=0) allrace=0.
   if (race1=0 and race_hispanic=1) allrace=2.
   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.
value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'
                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.
 
 
 
-----Original Message-----
From: Joseph Willey [[hidden email]]
Sent: Thursday, January 05, 2012 4:02 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: compute new race variable from 2 fields
 
Carol,
It would help if you would post the actual syntax that you are using.
 
Joe
________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]
Sent: Thursday, January 05, 2012 6:53 PM
Subject: compute new race variable from 2 fields
 
Hi all,
 
I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.
 
Field 1=Race1:    makes people select from only 1 of  9 different races.
Hispanic is not an option.
Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)
 
I created a new variable called allrace. Here is what i want to do:
 
If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1
 
My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.
 
Thanks for any syntax of wisdom.
 
Carol
 
=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
 
=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
 
=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
 
 
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

John F Hall

Glad to be of help.  Some of us old dogs, brought up on syntax, know some nice old tricks: also they’re much quicker in syntax than in GUI.  See the Old Dog, Old Tricks paper on my website (http://surveyresearch.weebly.com/old-dog-old-tricks.html )

 

In the old days when computing was so expensive (and slow) COMPUTE and RECODE were always much cheaper and quicker than IF or, worse still, multiple IFs, which pass through the data each time instead of just once.

 

Don’t forget to do crosstab checks on your recoded allrace (INTO allrace2):

 

cro allrace2 by race1 race_hispanic

 

Always best to be sure.

 

John Hall

 

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

Skype:   surveyresearcher1

Phone:    (+33) (0) 2.33.45.91.47

 

 

 

 

 

 

From: Parise, Carol A. [mailto:[hidden email]]
Sent: 06 January 2012 17:58
To: 'John F Hall'; [hidden email]
Subject: RE: compute new race variable from 2 fields

 

 

 

Holy %^&* - this worked so fast and easy!

 

Since i posted the table of the semi-working syntax...Here is the result of:

 

compute allrace = race_hispanic*100 +  race1 .

freq allrace.

 

All i need to do now is recode 100 to be hispanic and ge 101 as "multiple".

 

Thanks a bunch for your help!

 

Carol

 

Allrace

 

 

Frequency

Percent

Valid Percent

Cumulative Percent

 

Valid

.00 white

133067

66.0

66.0

66.0

1.00 black

12317

6.1

6.1

72.1

3.00 pacific islander

628

.3

.3

72.4

4.00 se asian

4960

2.5

2.5

74.9

5.00 indian continent

1235

.6

.6

75.5

6.00 american indian

309

.2

.2

75.7

7.00 chinese

4809

2.4

2.4

78.0

8.00 japanese

2215

1.1

1.1

79.1

9.00 philipino

6435

3.2

3.2

82.3

10.00 korean

1346

.7

.7

83.0

99.00 other-unknown

1751

.9

.9

83.9

100.00

31909

15.8

15.8

99.7

101.00

235

.1

.1

99.8

103.00

13

.0

.0

99.8

104.00

17

.0

.0

99.8

105.00

7

.0

.0

99.8

106.00

18

.0

.0

99.8

107.00

20

.0

.0

99.8

108.00

36

.0

.0

99.9

109.00

16

.0

.0

99.9

110.00

10

.0

.0

99.9

199.00

253

.1

.1

100.0

Total

201606

100.0

100.0

 

 

 

 

 

 

 

 

 

 

-----Original Message-----

From: John F Hall [[hidden email]]

Sent: Thursday, January 05, 2012 10:56 PM

To: [hidden email]; Parise, Carol A.

Subject: RE: compute new race variable from 2 fields

 

Have you thought about an intermediate step to combine the two variables.

You have 2 variables:

 

Race1 has codes 1 thru 9.

Race-hispanic has codes 0 and 1.

Looks as if you might have used 99 for missing.

 

I've often used the following trick.

 

compute allrace = race_hispanic*100 +  race1 .

freq allrace.

recode allrace (.........) [into allrace2] val lab allrace2 .....

 

on the combinations to produce a tidier grouping.

 

If you called your variables v1 and v2 or q1 and q2 etc., you would save yourself a lot of typing and avoid RSI!

 

John Hall

 

Email:     [hidden email] 

Skype:     surveyresearcher1

Phone:    (+33) (0) 2.33.45.91.47

 

 

 

 

-----Original Message-----

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Joseph Willey

Sent: 06 January 2012 01:58

Subject: Re: compute new race variable from 2 fields

 

Not what you originally said "If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1"

 

Think through it. Do your own work.

 

________________________________________

From: Parise, Carol A. [[hidden email]]

Sent: Thursday, January 05, 2012 7:54 PM

To: Joseph Willey; [hidden email]

Subject: RE: compute new race variable from 2 fields

 

This works and  computes the correct number of hispanics and whites but it counts people who are state that they are any other race and hispanic twice.

 

For example:

 

for Race1 = Black has  n=12317

 

using crosstabs, i learned that 235 people who are black, also checked Yes for Race_Hispanic.

 

allrace computes black as 12317+235 = 12552

 

what i need is to have those 235 people not be included in the allrace field.

 

make sense?

 

 

 

 

 

 

 

 

-----Original Message-----

From: Joseph Willey [[hidden email]]

Sent: Thursday, January 05, 2012 4:46 PM

To: Parise, Carol A.; [hidden email]

Subject: RE: compute new race variable from 2 fields

 

Even still, all of the people who are not white and not hispanic are sysmis.

 

Change    if (race1 ge 1 and race_hispanic=1) allrace=race_comb.

 

to --> IF (race1 GE 1) allrace=race1.

 

Joe

 

________________________________________

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]

Sent: Thursday, January 05, 2012 7:37 PM

Subject: Re: compute new race variable from 2 fields

 

Ahh...my error in my posting. race_comb should be RACE1. for this post, i change the name race_comb to RACE1 for simplicity.

 

this is the corrected syntax:

 

 

compute AllRace=$sysmis.

   if (race1=0 and race_hispanic=0) allrace=0.

   if (race1=0 and race_hispanic=1) allrace=2.

   if (race1 ge 1 and race_hispanic=1) allrace=race1.

value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'

                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.

 

-----Original Message-----

From: StatisticsDoc [[hidden email]]

Sent: Thursday, January 05, 2012 4:32 PM

To: Parise, Carol A.; [hidden email]

Subject: RE: compute new race variable from 2 fields

 

Carol,

 

What is race_comb and how was it computed?

 

Best,

 

Steve

 

 

 

-----Original Message-----

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A.

Sent: Thursday, January 05, 2012 7:16 PM

Subject: Re: compute new race variable from 2 fields

 

here you go!

 

the end result gives me the correct number of hispanics and whites. but then it gives me the number of people of other races who stated that they are hispanic.

 

compute AllRace=$sysmis.

   if (race1=0 and race_hispanic=0) allrace=0.

   if (race1=0 and race_hispanic=1) allrace=2.

   if (race1 ge 1 and race_hispanic=1) allrace=race_comb.

value labels allrace 0 'white' 1 'black' 2 'hispanic' 3 'pacific islander' 4 'se asian' 5 'indian continent'

                     6 'american indian' 7 'chinese' 8 'japanese' 9 'philipino' 10 'korean' 99 'other-unknown'.

 

 

 

-----Original Message-----

From: Joseph Willey [[hidden email]]

Sent: Thursday, January 05, 2012 4:02 PM

To: Parise, Carol A.; [hidden email]

Subject: RE: compute new race variable from 2 fields

 

Carol,

It would help if you would post the actual syntax that you are using.

 

Joe

________________________________________

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Parise, Carol A. [[hidden email]]

Sent: Thursday, January 05, 2012 6:53 PM

Subject: compute new race variable from 2 fields

 

Hi all,

 

I suspect this is easy for one or more of you. I have 2 fields for race/ethnicity in a file.

 

Field 1=Race1:    makes people select from only 1 of  9 different races.

Hispanic is not an option.

Field 2=Race_Hispanic:  makes people select whether or not they are hispanic (1=yes 0=no)

 

I created a new variable called allrace. Here is what i want to do:

 

If Race1=white and Race_Hispanic = Yes, then Allrace=Hispanic If Race1=any other race except for white and Race_hispanic =yes, then Allrace=Race1 If Race_Hispanic =no, Allrace =Race1

 

My syntax and it runs just fine. But, i'm screwing something up because my I am ending up with the total number of people in my Race_Hispanic=Yes field.

 

Thanks for any syntax of wisdom.

 

Carol

 

=====================

To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

 

=====================

To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

 

=====================

To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

 

 

Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

David Marso
Administrator
In reply to this post by parisec
the desired table (sans labels) is yielded from.
if (hispanic EQ 0) all_race=race1.
if (race1 eq 0) and (hispanic EQ 1) all_race=2.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: compute new race variable from 2 fields

parisec
Thanks David. It's great to have multiple ways to achieve the same results.

I appreciate everyones help. I was spinning my wheels on this one and it seemed like it should be so easy!



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Friday, January 06, 2012 9:30 AM
To: [hidden email]
Subject: Re: compute new race variable from 2 fields

the desired table (sans labels) is yielded from.
if (hispanic EQ 0) all_race=race1.
if (race1 eq 0) and (hispanic EQ 1) all_race=2.


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/compute-new-race-variable-from-2-fields-tp5124256p5126180.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD