Astounding, Thanks! I created a macro with the strings in it I want to search for and then tried to include it in the data step. Can you please tell me if this looks right to you: %macro check_gastro_hemg(dx); (substr(&dx,1,4) in ('5310', '5312', '5314', '5316', '5320', '5322', '5324', '5326', '5330', '5332', '5334', '5336', '5340', '5342', '5344', '5346', '5693')) or (&dx in ('53082', '53783', '53784', '56985', '56986')) or (substr(&dx,1,3)='578') or (substr(&dx,1,3)='535' and substr(&dx,5,1)='1') %mend; data want; set have; array diags {9} c_dx1-c_dx8 c_hcpc; found = 0; do _n_=1 to 9 until (found=1); if %check_gastro_hemg(diags) then then found=1; end; run;
... View more