Hi @Jima, since your email information is coming from a data file (Excel), you don't really need macro at all in this case. I've mocked up an example here:
/** Mock up email data **/
%let year=%sysfunc(year(%sysfunc(today())));
%let quarter=%sysfunc(qtr(%sysfunc(today())));
options emailsys=smtp emailhost = smtp.vccs.edu emailport = 25;
proc sql;
create table work.emails
(areax char(5), emailx char(40), name char(40), pdfrpt char(40), excelrpt char(40));
insert into work.emails
values('North','dave@mailinator.com','Dave Smith','C:\temp\rept1.pdf','C:\temp\rept1.xlsx')
values('South','mary@mailinator.com','Mary Smith','C:\temp\rept2.pdf','C:\temp\rept2.xlsx')
values('West', 'rick@mailinator.com','Rick Smith','C:\temp\rept3.pdf','C:\temp\rept3.xlsx');
quit;
run;
/** Send e-mail messages **/
filename reports email from="abc@xyz.edu";
data _null_;
set emails;
file reports;
put "Hello " name;
put / "Attached is a test email for " areax;
put / "Thanks!";
put "Jim";
put '!EM_TO!' emailx;
put "!EM_SUBJECT! WIOA PY&year. Q&quarter. Area: " areax;
put '!EM_ATTACH!' pdfrpt;
put '!EM_ATTACH!' excelrpt;
put '!EM_SEND!';
put '!EM_NEWMSG!';
put '!EM_ABORT!';
run;
There are a lot of SAS papers over the years on this topic: https://www.lexjansen.com/search/searchresults.php?q=email%20bulk
... View more