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-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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