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.;

 

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
  • 4 replies
  • 1189 views
  • 1 like
  • 4 in conversation