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

I have a SAS program that creates an Excel file that includes the current date as part of the file name. The data in the file is from the prior month.  How do I change the date to show the prior month in a MM-YYYY format?

 

Here is my current code that names the Excel file:

 

%let file1=/saswork/Corporate/Marketer_Services_Reporting/Data/_Scheduled Reports/CLASS Monthly/CLASS Completions-%QSYSFUNC(DATE(),worddate18.).xlsx;


ods excel file="&file1";

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
%SYSFUNC(intnx(month, %sysfunc(DATE()), -1, e), mmyyd6.)

View solution in original post

2 REPLIES 2
Reeza
Super User
%SYSFUNC(intnx(month, %sysfunc(DATE()), -1, e), mmyyd6.)
PaigeMiller
Diamond | Level 26
%let file1=/saswork/Corporate/Marketer_Services_Reporting/Data/_Scheduled Reports/CLASS Monthly/CLASS Completions-%sysfunc(today(),mmyyd7.).xlsx;

Although I think the formatting of MM-YYYY is a very poor choice because if you try to sort these files, they don't wind up in chronological order, they wind up with all the January files first regardless of year, and all the February files ...

 

Whereas yyyy-mm would always sort in chronological order.

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1568 views
  • 5 likes
  • 3 in conversation