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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.