I have a patient dataset where variables dx_code1-dx_code41 represent 41 diagnosis code variables. My objective is to output only observations in which at least one of the 41 diagnosis codes matches a particular code. I have 20 codes in mind, and I am trying to find an efficient way to program this in SAS. I am trying to set up a macro variable that is a list of constants, but the following code does not work: %let codes = '78060', '7784', '4659', '07999', '46611', '77989', '5990', '53081', '27651', '77189', '44619', '77982', '77931', '7746', 'V290', '77182', '7755', 'V070', '6910', '78791'; data patients; array a_dx dx_code1-dx_code41; do j = 1 to 20; flag = 0; do i = 1 to dim(a_dx); if a_dx(i) in: codes(j) then flag = 1; end; if flag > 0 then output; drop i flag; end; run; Any suggestions? Thanks!
... View more