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")
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.