BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kazimir900
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

In a data step

 

prev_year=year(intnx('month',today(),-1));
--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

In a data step

 

prev_year=year(intnx('month',today(),-1));
--
Paige Miller
kazimir900
Calcite | Level 5

Thanks for your quick help!

 

I've tried something like that before but some how my code didn't work...but yours does!

PeterClemmensen
Tourmaline | Level 20

@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;
novinosrin
Tourmaline | Level 20
%let current_date=%sysfunc(today());

%let prev_month=%sysfunc(intnx(mon,&current_date,-1),monyy7.);

%put &=prev_month;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 686 views
  • 1 like
  • 4 in conversation