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";
%SYSFUNC(intnx(month, %sysfunc(DATE()), -1, e), mmyyd6.)
%SYSFUNC(intnx(month, %sysfunc(DATE()), -1, e), mmyyd6.)
%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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.