Are the comparison variables numeric date variables in the input dataset such as:
mis_dt = %bquote('&eom_tera') and stmtmth between %bquote('&bom_tera') and %bquote('&eom_tera')
You seem to be comparing them against characters.
Try:
%macro test(m,d,y);
%let eom_dt=%sysfunc(mdy(&m,&d,&y));
%let eom=%sysfunc(intnx(month,&eom_dt,0,e),yymmddn8.);
%let eom_tera=%sysfunc(intnx(month,&eom_dt,0,e),date9.);
%let bom_tera=%sysfunc(intnx(month,&eom_dt,0,b),date9.);
%put &eom &eom_tera &bom_tera;
options SPOOL compress=yes;
proc sql;
create table _9statement_data_&eom as
select mis_dt as MIS_DT2
, crdnbr as CRDNBR2
, CSHLCY as CASH_LIMIT
, stmtmth as STMT_DT
from fc.INT_CRD_SALE_STMT_SNAPSHOT_M
where crdnbr in (select distinct crdnbr from STMT_1) and
mis_dt = "&eom_tera"d
and stmtmth between "&bom_tera"d and "&eom_tera"d
order by crdnbr
;
quit;
%mend;
%test(1,31,2020);
... View more