Hello again,
I've been banging my head on this and thought I'd turn to SAS Community for some advice.
I have a government data set. The data has 15 racial categories. It is NOT 0/1 coded like I originally thought. People can select up to 15 of the 15 categories (so, someone could choose from 1-15 identifiers). The data is coded like 1=chinese/0-didn't choose, 2=native alaskan/0=didn't choose; 3= burmese/0=didn't choose.
I am struggling to code for identifying multiracial individuals.
I had originally planned that 0=didn't choose and 1=chose that identifier, so anyone with a total of greater than 1 had chosen multiple racial identifiers and can be labeled "multiracial."
How would I change the non 1 numbers for "chose this" into 1s? So instead of a person choosing native alaskan (2) and burmese (3) and equaling 5, I would want them to equal 2 (native alaskan-1, burmese=1).
Hope this makes sense. Thanks!!!
SAS treats 0 (or missing) as FALSE and any other number as TRUE. So to convert your 2/0, 3/0,.... variables into 1/0 variables you can just do:
chinese = not not chinese;
So 0 will go to 1 and then back to 0. Any other number, like 1,2,3,etc will go to 0 and then back to 1.
SAS treats 0 (or missing) as FALSE and any other number as TRUE. So to convert your 2/0, 3/0,.... variables into 1/0 variables you can just do:
chinese = not not chinese;
So 0 will go to 1 and then back to 0. Any other number, like 1,2,3,etc will go to 0 and then back to 1.
wow, i should have gotten that. Thanks!!!
data test;
do chinese=0 to 10;
chinese_test=^^chinese;
output;
end;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.