DATA Step, Macro, Functions and more

file saving with sas date format

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 134
Accepted Solution

file saving with sas date format

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

 

 

 


Accepted Solutions
Solution
‎05-24-2017 04:55 PM
Super User
Posts: 5,499

Re: file saving with sas date format

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.

View solution in original post


All Replies
Solution
‎05-24-2017 04:55 PM
Super User
Posts: 5,499

Re: file saving with sas date format

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.

Frequent Contributor
Posts: 134

Re: file saving with sas date format

Posted in reply to Astounding

Thanks for your assistance

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 122 views
  • 2 likes
  • 2 in conversation