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")
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.