BookmarkSubscribeRSS Feed
Michael_B-T
Calcite | Level 5

Hello

 

I'm having a slight issue with attaching a file to my macro mail.

The culprit as far as I am aware my dynamic date name function: &today

This is my attachment code:

 

 

attach=("\\F:\DI\WR\WeeklyReport_&today" content_type="application/xlsx");

 

 

For which I receive this error: ERROR: Error opening attachment file
Physical file does not exist,

 

I've tried entering the file name exactly WITHOUT using my &today macro and IT DID WORK.

I've also tried adding .xlsx to the end of the target attachment string: 

 

 

attach=("\\F:\DI\WR\WeeklyReport_&today".xlsx content_type="application/xlsx");

 

This however did not help and gave me the same error (as If SAS did not detect the full space between &today and xlsm)

 

The only half-way solution that I found was adding a star (*) to the attachment target string, which would indeed attach the file however in text format and not xlsm.

attach=("\\F:\DI\WR\WeeklyReport_&today*" content_type="application/xlsx");

 

Any ideas would be hugely appreciated.

 

 

Michael

1 REPLY 1
ballardw
Super User

Try

 

"\\F:\DI\WR\WeeklyReport_&today..xlsx"

strings have to be in quotes.

note the two periods. That is intentional as the first one signals the end of the macro variable value and the second is the period in the file name.

 

Of course if there is no file with the name as resolved then you will still get the error.

 

Run this code and examine the log for how the values resolve.

%let today = 31OCT2018;

%put With 2 periods "\\F:\DI\WR\WeeklyReport_&today..xlsx";
%put without 2 periods "\\F:\DI\WR\WeeklyReport_&today.xlsx";

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 749 views
  • 2 likes
  • 2 in conversation