BookmarkSubscribeRSS Feed
gtucke1
Fluorite | Level 6

The original variable for race has the following categories for participants:

1 = White

2 = African American/Black

3 = Asian

4 = Other

 

For my analysis, I am only interested in White and African American/Black participants. I want to create a new variable: race_dich_pt using the if then else statement. What do I do with categories 3 and 4? 

 


if race = 1 then race_dich_pt = 1; /*White*/
else if race = 2 then race_dich_pt = 0; /*African American/Black*/
else if race = 3 then race_dich_pt =

else if race = 4 then race_dich_pt = 

else if race = . then race_dich_pt = .;

 

 

4 REPLIES 4
Reeza
Super User

Depends on what you're doing. 

In some cases you may exclude them entirely. In other cases, you would include them as a third group combined, such as other.

ballardw
Super User
if race = 1 then race_dich_pt = 1; /*White*/
else if race = 2 then race_dich_pt = 0; /*African American/Black*/
else  race_dich_pt = . ;

But you will want to make sure that any analysis or write up explains that using this variable should exclude XX% of records where XX is the percent of everything non-White and non-Black.

gtucke1
Fluorite | Level 6

Thank you very much for your help with the code and suggestion for how to describe the other %.

Rick_SAS
SAS Super FREQ

The other thing you can do is use a WHERE clause to exclude the observations you don't want. Then there is no need to recode the data. For example,

proc freq data=Have;
   where Race=1 or Race=2;
   tables Race;
run;