Hi
You can use the INTNX function to do this, depending on how you want to use it, you could use the SAS Macro language to create the start end end values. Please note the macro variables currently just contain the correct string representation to actually make a proper date value out of it, you need to put them into quotes and add the DT so that in the end, you get "01FEB2018:00:00:00"dt
%let currentDT = %sysfunc( datetime() );
%let prevMonthStart = %sysfunc( intnx(DTMONTH, ¤tDT, -1, B), datetime19.);
%let prevMonthEnd = %sysfunc( intnx(DTMONTH, ¤tDT, 0, B), datetime19.);
%put &=prevMonthStart &=prevMonthEnd;
or your filter expression in a query looks like
t1.dt BETWEEN intnx("DTMONTH", datetime(), -1, "B") AND intnx("DTMONTH", datetime(), 0, "B")
Hi
You can use the INTNX function to do this, depending on how you want to use it, you could use the SAS Macro language to create the start end end values. Please note the macro variables currently just contain the correct string representation to actually make a proper date value out of it, you need to put them into quotes and add the DT so that in the end, you get "01FEB2018:00:00:00"dt
%let currentDT = %sysfunc( datetime() );
%let prevMonthStart = %sysfunc( intnx(DTMONTH, ¤tDT, -1, B), datetime19.);
%let prevMonthEnd = %sysfunc( intnx(DTMONTH, ¤tDT, 0, B), datetime19.);
%put &=prevMonthStart &=prevMonthEnd;
or your filter expression in a query looks like
t1.dt BETWEEN intnx("DTMONTH", datetime(), -1, "B") AND intnx("DTMONTH", datetime(), 0, "B")
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.