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