Hello, I think it's possible but am not sure how to do it. I have a CCW data with multiple ICD variables. The ICD variables are in this format ICD_DGNS_CD1, ICD_DGNS_CD2, and so on. I am writing a sql code to pull all OUD within the data using the ICD codes. In the where statement, I don't want to write the entire variables out (e.g., icd_dgns_cd1) in my code so am think there should be a macro code to call the ICD variables. I tried something like ; where (substr(icd_&,1,5) in (&icd.) but it didn't work. %let icd= '30400', '30401', '30402', '30403', '30470', '30471', '30472', '30473',...... ; proc sql;
create table oud as
select id, clm_id, dob_dt, icd_dgns_cd1, icd_dgns_cd2, icd_dgns_cd3, icd_dgns_cd4,
icd_dgns_cd5, icd_dgns_cd6, icd_dgns_cd7, icd_dgns_cd8
from bcarclms2021
where (substr(icd_dgns_cd1,1,5) in (&icd.) or substr(icd_dgns_cd2,1,5) in (&icd.) or substr(icd_dgns_cd3,1,5) in (&icd.) or substr(icd_dgns_cd4,1,5) in (&icd.) or
substr(icd_dgns_cd5,1,5) in (&icd.) or substr(icd_dgns_cd6,1,5) in (&icd.) or
substr(icd_dgns_cd7,1,5) in (&icd.) or substr(icd_dgns_cd8,1,5) in (&icd.) ;
quit;
... View more