Hi,
I am saving an excel file with a date variable as part of the file name. my problem is that the file is saved using SAS date format rather than a calander date
here is a sample code that I am using
data _null_;
format week comma10.0;
format date MONYY.;
week = 1;
date = intnx('month',today(),0);
call symputx('week',week);
call symputx('date',date);
run;
%let label = &date. week &week.;
%put &label.;
data _null_;
file cmds;
put "[save.as(%bquote("C:\Report &label..xlsx"))]";
put '[CLOSE()]';
run;
file is saving like this
Report 20940 week 1.xlsx
I want file to save as Report May2017 week 1.xlsx
by somehow converting sas date format to monthyear date format
Thanks
You can do this by changing the value assigned to &LABEL. I'm going to show you something a little different than what you asked for:
%let label = %sysfunc(putn(&date., yymmn6.)) week &week.;
This will give you 201705 instead of May2017. That way, all your file names will alphabetize in chronological order.
You can do this by changing the value assigned to &LABEL. I'm going to show you something a little different than what you asked for:
%let label = %sysfunc(putn(&date., yymmn6.)) week &week.;
This will give you 201705 instead of May2017. That way, all your file names will alphabetize in chronological order.
Thanks for your assistance
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.