I'm trying to write some code that will generate today's date then add that to a string to search for a file matching that date. Problem I'm having is the concatenation of the string is producing spaces before the macro despite trying different trim options. Been a few years since working with SAS so I'm rusty.
data _null_ ;
x = date() ;
format x yymmdd10. ;
xx = compress(put(x, yymmdd10.), '-') ;
call symput('datepull', xx ) ;
call symput('testfile', "\\vanfile\EnterpriseBusinessIntelligence\Tools Stuff\External Source Files\Casino\PlayPlanner\PlayerExtract_Precommitment_"||&datepull||'000000.xls');
/* call symput('testfile', "Casino\PlayPlanner\PlayerExtract_Precommitment_"||&datepull||'000000.xls');*/
run;
%put &datepull ;
%put &testfile ;
41 %put &datepull ;
20180608
42 %put &testfile ;
\\vanfile\EnterpriseBusinessIntelligence\Tools Stuff\External Source Files\Casino\PlayPlanner\PlayerExtract_Precommitment_
20180608000000.xls
Use CALL SYMPUTX instead of CALL SYMPUT
Thanks.
You have a couple of issues, beginning with the fact that &DATEPULL doesn't exist when it is needed to create &TESTFILE. I would recommend a two-step fix.
First, remove all reference to &DATEPULL from the DATA step.
Then create &TESTFILE after the DATA step is over, using two statements:
%let datepull = &datepull;
%let testfile = \\vanfile\EnterpriseBusinessIntelligence\Tools Stuff\External Source
Files\Casino\PlayPlanner\PlayerExtract_Precommitment_&datepull.000000.xls;
The first %LET will remove any leading or trailing blanks from &DATEPULL. The second %LET creates the string you need, but double-check the spacing to make sure I got it right (particularly this part: External Source Files).
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.
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.