Hi @Mick_lb
You need to be very careful with dates in macro variables.
It should not be formatted to be used for further calculation
Typically, 01JAN2017 (which is human-readable) is stored as the numeric value 20820 by SAS (= number of days since 01JAN1960)
Best,
%let date=01JAN2017:00:00:00;
%put ===> &date;
%let date_2=%sysfunc(datepart(%sysfunc(inputn(&date,datetime18))));
%let last_day=%sysfunc(day(%sysfunc(intnx(month,&date_2,-1,end))));
%let p_month=%sysfunc(month(%sysfunc(intnx(month,&date_2,-1,end))));
%let p_year=%sysfunc(year(%sysfunc(intnx(month,&date_2,-1,end))));
%put ===> &last_day.;
%put ===> &p_month.;
%put ===> &p_year.;
... View more