BookmarkSubscribeRSS Feed
Klakola
Calcite | Level 5

 

 

Is there a way to reference macros in outmail in sas for:

path name where the attachment is kept?

 

*Is there also a way to reference a macro for email? I have multiple users running the report and would rather not have the user have to scroll down to hardcode their own email if this can be done 'up front' in a let statement.

 

/*EMAIL*/

%let fileref = 'file name' <= this dynamically changes/user sets 

%let path = 'sas/folder/data' <= where data/information is stored. path is changed by user (person running report saves data to their work folder)

 


filename OUTMAIL email

subject = '(&fileref) Report'

from = 'me@mail.com' <-can a macro be used here as well so a user doesn't scroll down to hardcode an email value?

to = them@mail.com'

 

 

attach =('/&path/Report.xls' <-can a macro be used for a path so a user doesn't scroll down to hardcode?

content_type='application/xls');

 

 

2 REPLIES 2
ballardw
Super User

And you may not want the quotes in the %let assignments for those macro variables.

 

If you use

%let path = 'sas/folder/data'

then when this resolves (assuming you replace the single quotes to double quotes so it can resolve) then

 

attach =("/&path/Report.xls"

would resolve to

 

attach =("/'sas/folder/data'/Report.xls"

which is almost certainly not the correct path. Color and font changed to indicate the probable issue.

 

Macro variables are always text, so you don't need the quotes to tell the processor that you want a character value. The quotes become part of the value.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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