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

## Problems with If-Then Statements

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
Super User

## Re: Problems with If-Then Statements

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.

5 REPLIES 5
Meteorite | Level 14

## Re: Problems with If-Then Statements

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;
Fluorite | Level 6

## Re: Problems with If-Then Statements

I have included the results in the attachment below.

Meteorite | Level 14

## Re: Problems with If-Then Statements

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.

Super User

## Re: Problems with If-Then Statements

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.

Fluorite | Level 6

## Re: Problems with If-Then Statements

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!

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