Hello,
I am inexperienced in SAS and need some help.
I am analyzing some student survey data which had a ‘race’ variable where respondents had the option to select more than one race category. Because of that I have 6 separate race variables.
Variable name | Label |
Q3_1 | American Indian or Alaska Native |
Q3_2 | Asian |
Q3_3 | White |
Q3_4 | Black or African American |
Q3_5 | Hispanic or Latino |
Q3_6 | Native Hawaiian or Other Pacific Islander |
I am trying to create one Race variable for analysis and want to add a category of ‘multiracial’ for any person who selects more than one Race. I will want SAS to drop the race categories (Q3_1-Q3_6) for a person who is ‘multiracial’ so that I don’t have multiple lines of data per person however I am unable to do that (highlighted section) and will appreciate any help.
data five;
set four;
length race $ 16;
keep id race;
if Q3_1 then do;
race='American Indian or Alaska Native';
output;
end;
if Q3_2 then do;
race='Asian';
output;
end;
if Q3_3 then do;
race='White';
output;
end;
if Q3_4 then do;
race='Black or African American';
output;
end;
if Q3_5 then do;
race='Hispanic or latino';
output;
end;
if Q3_6 then do;
race='Native Hawaiian or Other Pacific Islander';
output;
end;
if q3_3 and q3_5 then do;
race='multiracial';
drop q3_3 q3_5;
output;
end;
run;
data six;
merge four five;
by id;
run;