Hey SAS Community,
i want to extract just the year of the privious month from the current date in SAS Enterprise Guide. But i can't figure out how to...
Thanks for your help!
Lars
In a data step
prev_year=year(intnx('month',today(),-1));
In a data step
prev_year=year(intnx('month',today(),-1));
Thanks for your quick help!
I've tried something like that before but some how my code didn't work...but yours does!
@kazimir900 hi and welcome to the SAS Community!
You can do something like this
data _null_;
yearofprevmonth=year(intnx('month', today(), -1, 'b'));
put yearofprevmonth=;
run;
%let current_date=%sysfunc(today());
%let prev_month=%sysfunc(intnx(mon,¤t_date,-1),monyy7.);
%put &=prev_month;
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.