Edited: added SAS table file as well as the output needed. Thank you to those who have already responded. I have not had a chance to try the code in responses at this time. I'm new to this posting questions. I'm usually able to recycle code from other programs or code I find online. Hi everyone, I have a variable where is tells me if the race is just alone or "Two or more races". For the ones where race is 'race, alone', simple coding: if SINGLE_TOM_RACE NE 'Two or more races' THEN DO;
if SINGLE_TOM_RACE = 'American Indian/Alaskan Native, Alone' then race1 = 'R1';
else if SINGLE_TOM_RACE = 'Asian, Alone' then race1 = 'R2';
else if SINGLE_TOM_RACE = = 'Black/African American, Alone' then race1 = 'R3';
else if SINGLE_TOM_RACE = 'Native Hawaiian or other Pacific Islander, Alone' then race1 = 'R4';
else if SINGLE_TOM_RACE = 'White, Alone' then race1 = 'R5';
else if SINGLE_TOM_RACE = 'Other/Unknown' then race1= 'UNK';
else race1='';
end; I'm having brain freeze on when SINGLE_TOM_RACE is 'Two or more races'. I know I need an array. Each observation is unique. Race categories run from Race1a -- Race15a. Data dictionary is in the table below: column code Decedent's race literal IMPORT RESULT NEEDED RACE1a Y, N, U White R5 RACE2a Y, N, U Black or African American R3 RACE3a Y, N, U American Indian or Alaska Native R1 RACE4a Y, N, U Asian Indian R2.01 RACE5a Y, N, U Chinese R2.06 RACE6a Y, N, U Filipino R2.08 RACE7a Y, N, U Japanese R2.11 RACE8a Y, N, U Korean R2.12 RACE9a Y, N, U Vietnamese R2.19 RACE10a Y, N, U Other Asian R2 RACE11a Y, N, U Native Hawaiian R4.01.001 RACE12a Y, N, U Guamanian or Chamorro R4.02.001 RACE13a Y, N, U Samoan R4.01.002 RACE14a Y, N, U Other Pacific Islander R4 RACE15a Y, N, U Other UNK IMPORT FILE HAS RACE VARIABLES RACE1-RACE5 AVAILABLE FOR MULTIRACIAL CASES It's also in the attached excel file. During my searches for similar answers, I've only found responses for duplicate observations and not unique/ distinct observations. I know that I need the first - n 'Y' in each row, but I am completely blanking on the way to do that array. From the searches I have found, this code below seems to be on the right track, but I'm not sure. if SINGLE_TOM_RACE = 'Two or more races' then do;
array race{15} race1a-race15a;
do i ????????(first) then first=race(i);
else if race(i) ^= first then second = race(i);
end;
drop i;
run; The question marks are there to replace the 'missing' from the original code. There are no missing values in the observations. Any help is greatly appreciated. I'm usually recycling code rather than writing it myself because I know someone else has already written the code or it's similar enough that I can edit it to fit my needs. Needed Output: id race1 race2 race3 race4 race5 434 R5 UNK 600 R5 R2.08 682 R3 R1 786 R5 R1 1036 R5 R3 1632 R5 R3 R2.11 1911 R3 R2 2215 R5 R2.08 2391 R5 R3 3087 R3 R1 UNK 3314 R5 R3 4026 R5 R3 R1 R2 R4 Thanks!
... View more