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

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!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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.

klongway
Calcite | Level 5

wow, i should have gotten that. Thanks!!!

novinosrin
Tourmaline | Level 20

data test;
 do chinese=0 to 10;
  chinese_test=^^chinese;
  output;
 end;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1244 views
  • 1 like
  • 3 in conversation