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

I have a variable (race) that has 15 levels.  The levels are coded 1-13, 888, 999.  This was a check all that apply question, so multiple codes appear in the same cell, seperated by a comma (,).  In the past I have used the find function to create flag variables for each level (see below for code), however because the variable levels include more than one digit this produces inaccurate values.  For example a respondent that selected level 13 is being counted as level 3 as well.

Screenshot 2024-10-03 112249.jpg

 

data two;
    set one;
    if find(race, '1')>0 then race_1=1;
    if find(race, '2')>0 then race_2=1;
    if find(race, '3')>0 then race_3=1;
    if find(race, '4')>0 then race_4=1;
    if find(race, '5')>0 then race_5=1;
    if find(race, '6')>0 then race_6=1;
    if find(race, '7')>0 then race_7=1;
    if find(race, '8')>0 then race_8=1;
    if find(race, '9')>0 then race_9=1;
    if find(race, '10')>0 then race_10=1;
    if find(race, '11')>0 then race_11=1;
    if find(race, '12')>0 then race_12=1;
    if find(race, '13')>0 then race_13=1;
    if find(race, '888')>0 then race_888=1;
    if race=999 or race=' ' then race_999=1;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
1 REPLY 1

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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
  • 1 reply
  • 647 views
  • 0 likes
  • 2 in conversation