BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bnd
Fluorite | Level 6 bnd
Fluorite | Level 6

Hello,

 

I am having some issues with the if-then statement. I am trying to make white and black into a new variable called white_black so that I can compare the two using just one variable. Both the white and black variables are coded as 1 if a person is that race and 0 if they are not. There are a total of 320 white individuals and 76 black individuals. When I place the variables into the if-then statement, it seems that there are 2 fewer people included in either group. For example, there may be 320 for white and 74 for black. I am not sure why this is happening. My code is provided below. 

 

if white = 1 then black_white = 1

if black = 1 then black_white = 0

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Your "problem" is caused by 7 people who consider themselves neither af_amer nor white, and 2 who think they are af_amer and white.

So instead of 401, your if/then will add up to 396.

Correction: you'll have 7 missing, 320 "white", and 74 "black", because with the double identification white overrides black.

 

PS your question is a nice illustration of Maxim 3 and the usefulness of proc freq.

View solution in original post

5 REPLIES 5
ed_sas_member
Meteorite | Level 14
Hi @bnd
Could you please run a proc freq to look at the data and share the result?

Proc freq data=have;
Tables white * black / nocum nopercent;
Run;
bnd
Fluorite | Level 6 bnd
Fluorite | Level 6

Hi @ed_sas_member,

 

I have included the results in the attachment below.

 

ed_sas_member
Meteorite | Level 14

Hi @bnd 

Thank you for the output.

It seems that 2 people have white=1 and Af_amer=1 -> maybe you should clean these data first.

Capture d’écran 2020-02-22 à 09.11.55.png

Kurt_Bremser
Super User

Your "problem" is caused by 7 people who consider themselves neither af_amer nor white, and 2 who think they are af_amer and white.

So instead of 401, your if/then will add up to 396.

Correction: you'll have 7 missing, 320 "white", and 74 "black", because with the double identification white overrides black.

 

PS your question is a nice illustration of Maxim 3 and the usefulness of proc freq.

bnd
Fluorite | Level 6 bnd
Fluorite | Level 6

Thanks! @Kurt_Bremser @ed_sas_member 

 

I kept trying to figure out what was going on exactly. After running the frequency table and reading over both of your comments, everything made perfect sense. 

 

Thanks so much for your help!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1007 views
  • 1 like
  • 3 in conversation