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

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 962 views
  • 0 likes
  • 3 in conversation