BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tparvaiz
Obsidian | Level 7

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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

2 REPLIES 2
Astounding
PROC Star

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.

tparvaiz
Obsidian | Level 7

Thanks for your assistance

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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