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.

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