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: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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