One way is to search using the WHICHC, or WHICHN for numeric values, with the array. The WHICHC function returns the position the value is first found in a list of values or 0 if not found. So if you get a zero result there isn't a match.
It also doesn't require comparing each value, so might simplify your current "loop" approach.
For one combination
If whichc('W5511', of DX(*)>0 and whichc('Y9271',of DX(*))>0 then <this is one of the combinations and do what you will>;
( ) around each comparison and an "or" between comparisons would probably be the easiest for multiple comparisons.
If you are only providing one flag variable you could also check to see if it that has already been set. If it has then no need to even do the check.
If your list of values was "nice" as in sequential or comparing all of the first values with all of the second values then this could be accomplished with some iterated do loops but that does not seem to be the case here.
Your example code wouldn't quite run. You would have to have something more like (still not quite valid) but needs the loop index with the array.
farminj=0;
array DX $ dxp diag1-diag25 ECode1-Ecode6;
do i =1 to 32;
if DX[i] in: ('various single ICD10 codes') then farminj=1;
end;
This does compare every value in the array with the codes. If you have a large data set that adds up for time. You might consider:
farminj=0;
array DX $ dxp diag1-diag25 ECode1-Ecode6;
do i =1 to 32;
if DX[i] in: ('various single ICD10 codes') then do;
farminj=1;
leave;
end;
end;
Which will exit the do loop at the time the first match is found and the Farming value is set to 1.
... View more