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.
%let FileName=ABC-- %sysfunc(today(), yymmddn8.);
%put &FileName;
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.
%let FileName=ABC-- %sysfunc(today(), yymmddn8.);
%put &FileName;
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.;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.