Hi, Can you try and see if something like this works... Options mprint; %macro data(); data work.test; set idb.cv00on; WHERE _N_ > 0 %if &CIRCUIT_COUNT >= 0 %then %do; AND trim(left(CIRCUIT)) IN ( %DO I = 1 %TO &CIRCUIT_COUNT; %if &i=1 %then %do;. "%trim(%left(&CIRCUIT))" %end; %else %do; "%trim(%left(&&CIRCUIT&I))" %end; %END; ) %END; %if &DISTRICT_COUNT >= 0 %then %do; AND trim(left(DISTRICT)) IN ( %DO I = 1 %TO &DISTRICT_COUNT; %if &i=1 %then %do;. "%trim(%left(&DISTRICT))" %end; %else %do; "%trim(%left(&&DISTRICT&I))" %end; %END; ) %END; %if %length(&DOCKET) >= 0 %then %do; and DOCKET = "&DOCKET" %end; %if %length(&FILEDATE_min) >= 0 %then %do; and FILEDATE >= "&FILEDATE_min"d %put a %end; %if %length(&FILEDATE_MAX) >= 0 %then %do; and FILEDATE <= "&FILEDATE_max"d %end; %if %length(&termDATE_min) >= 0 %then %do; and termDATE >= "&FILEDATE_min"d %put a %end; %if %length(&termDATE_MAX) >= 0 %then %do; and termDATE <= "&FILEDATE_max"d %end; %if &DISTRICT_COUNT >= 0 %then %do; AND trim(left(NOS)) IN ( %DO I = 1 %TO &NOS_COUNT; %if &i=1 %then %do;. "%trim(%left(&NOS))" %end; %else %do; "%trim(%left(&&NOS&I))" %end; %END; ) %END; %if &disposition_COUNT >= 0 %then %do; AND disposition IN ( %DO I = 1 %TO &disposition_COUNT; %if &i=1 %then %do;. &disposition %end; %else %do; ,&&disposition&I %end; %END; ) %END; ; run; %mend; %data
... View more