Hello, I am using SAS 9.4 and I have a dataset with secondary diagnosis ICD10 codes. There are up to 120 secondary diagnosis codes listed. My goal is to build an array for the diagnosis codes and create a flag for any secondary diagnosis with a mention of alcohol. All the alcohol diagnosis codes start with an 'F10___' but depending on the specifics the code could be 3 more digits and there are too many ICD10 codes to just manually type out. I am trying to write a code to flag the observations with an alcohol related code associated to it by creating an array then doing a do loop that will select a partial string from the 120 variable array. I am not getting an error but my results come back as 0 observations which I know is incorrect based on spot checking one of the secondary code variables. Below is the code I am working with. data cancer3; set cancer; array CDiagcode {1:120} DX1-DX120; *build array of DX codes; do j = 1 to 120; if CDiagcode {j} = FIND(of CDiagcode{j}, 'F10') then do; *if secondary diagnosis is for alcohol*; substance10 = 1; SFlag = 1; *flag 2; end; else if SFlag not in (1) then do; *if no alcohol diagnosis DM = 0; substance10 = 0; SFlag = 0; *flag 3; end; end; run;
... View more