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