DATA Step, Macro, Functions and more

SAS Email Macro

Reply
Occasional Contributor
Posts: 16

SAS Email Macro


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.

Super Contributor
Super Contributor
Posts: 3,174

Re: SAS Email Macro

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.

Occasional Contributor
Posts: 16

Re: SAS Email Macro


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;




Super Contributor
Super Contributor
Posts: 3,174

Re: SAS Email Macro

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.

Ask a Question
Discussion stats
  • 3 replies
  • 368 views
  • 3 likes
  • 2 in conversation