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

Hi, I'd like to create a macro variable holding a file name that will be used in proc export.  The filename will contain a company and a date, like "ABC -- 20200605.xlsx".  First there what is a better way than adding in layers of %sysfunc?


%let FileName=%sysfunc(cats(ABC, %sysfunc(putn(%sysfunc(today()), yymmddd.))));
%put &FileName;

 

Second, SAS returned ABC--9, which does not have a date.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
%let FileName=ABC-- %sysfunc(today(), yymmddn8.);
%put &FileName;

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

You don't need CATS for concatenation in macro variable

%let filename = %str(ABC -- )%sysfunc(putn(%sysfunc(today()),yymmddn.)).xlsx;
%put &=filename;

The whole thing would probably be easier in a DATA step, no %SYSFUNC needed then.

--
Paige Miller
AndyTam
Fluorite | Level 6
Thanks for your help too
novinosrin
Tourmaline | Level 20
%let FileName=ABC-- %sysfunc(today(), yymmddn8.);
%put &FileName;
ballardw
Super User

One question: is that file name supposed to have a space on either side of the -- , only before, only after, or no space?

 

%let FileName1=ABC-- %sysfunc(today(), yymmddn8.);
%let FileName2=ABC -- %sysfunc(today(), yymmddn8.);
%let FileName3=ABC --%sysfunc(today(), yymmddn8.);
%let FileName4=ABC--%sysfunc(today(), yymmddn8.);
%put Filename1:&filename1.
 Filename2:&filename2.
 Filename3:&filename3.
 Filename4:&filename4.;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 455 views
  • 1 like
  • 4 in conversation