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";

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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