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.;
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: