BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
paulsparrow
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use CALL SYMPUTX instead of CALL SYMPUT

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Use CALL SYMPUTX instead of CALL SYMPUT

--
Paige Miller
paulsparrow
Obsidian | Level 7

Thanks.

Astounding
PROC Star

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 3 replies
  • 1664 views
  • 0 likes
  • 3 in conversation