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.
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!
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.
Ready to level-up your skills? Choose your own adventure.