I am trying to make a bit of code that will take a string from my dataset in excel and turn it into a number. However, there are some observations that have multiple groups and my code is only grabbing the first one it sees and I would like it to somehow recognize that there are multiple different groups in the same observations and classify it as other. Here is my example: Have: Where I want White to be coded as 1, African American to be coded as 2 etc and if there are two different races then I want 6 for other. Here is my code for attempting to do this: data race;
input ID $ Race $;
datalines;
1 White
2 AfricanAmerican 3 White/AfricanAmerican 4 Hispanic 5 Hispanic/AfricanAmerican 6 NativeAmerican 7 PacificIslander 8 Other 9 PacificIslander/NativeAmerican 10 Hispanic/White
; data race; if find (Race, "White") ge 1 then code = 1; else if find (Race, "AfricanAmerican") ge 1 then code = 2; else if find (Race, "Hispanic") ge 1 then code = 3; else if find (Race, "NativeAmerican") ge 1 then code = 4; else if find (Race, "PacificIslander") ge 1 then code = 5; else if find (Race, "Other") ge 1 then code = 6; run;
... View more