BookmarkSubscribeRSS Feed
thomask23
Fluorite | Level 6


I am new to SAS. I have created a macro to email users and send attachments based on RecType.    I would like to use a macro  to send these emails.   Is it possible to use a macro that uses a  list where it references recType and email address for my current macro? So
the program sees what reccd it is, then sets the email macro variable &email. or something to whatever the corresponding email address is on that list.  Then in the call execute statement the email goes to you, and “&email.” 
:smileygrin: A macro in a macro.

3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10

Yes, a DATA step could be used to read a file / list with INPUT, then construct the macro-invocation command you mention with the CALL EXECUTE.   Your EMAIL-generation macro would need to take any variable information as the macro variable parameters supplied when your DATA step invokes the CALL EXECUTE.

Scott Barry

SBBWorks, Inc.

thomask23
Fluorite | Level 6


Would the syntax for the email macro be something along the lines of?

%macro send_mail(RecType= , Contact=);

data Temp_Email;

set KT.email_list;

If RecType=&RecType then do

run;

%Mend;




sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10

The EMAIL macro would generate the EMAIL...invoked iteratively for each EMAIL-recipient from your list (possibly a SAS file/member).  The macro would contain SAS code that likely uses FILENAME and EMAIL engine to generate your EMAILs.

A DATA step would be used to drive the CALL EXECUTE processing -- you must use SAS code to build the SAS macro invocation statements as the argument passed to CALL EXECUTE.

You have to start with generating / compiling your EMAIL-recipient list, either from an external information source or possibly directly from a SAS file.

Suggest you search the Internet with argument "data step call execute invoke macro" for documentation / example references.

Scott Barry

SBBWorks, Inc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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