Hi!
I have to send an email as follows:
data _null_;
file sendit email
to=("&email_address")
subject="TEST";
put "Hello";
run;
However I have to send for more than one email. E-mail addresses are in a table with email and group fields. Example:
email group
A X
B X
I want to extract from the table the emails that belong to the same group but I am only able to extract the first email (in this case A). I have tried to create an array but when I put the array as the variable &email_address I can not send the mail. The email addresses should look like this: "A" "B".
Is there any way to parameterize the sending of the email so that the emails of the people to whom I want to send the mail are extracted from the table?
Thank you for your help!
An easy solution is to use a PROC SQL step to create a macro variable containing a list of values from a specific table.
DATA WORK.Have;
FORMAT emailaddr $50.;
INFORMAT emailaddr $50.;
INPUT emailaddr;
CARDS;
AdamApple@gmail.com
BillBobington@yahoo.com
ChuckCooper@hotmail.com
;
PROC SQL NOPRINT;
SELECT CAT('"',STRIP(emailaddr),'"') AS QtdEmail INTO :EmailAddrList Separated by ' '
FROM WORK.Have;
QUIT;
%PUT &=EmailAddrList.;
When the new macro variable, 'EMAILADDRLIST' resolves, it looks like this (in the log):
EMAILADDRLIST="AdamApple@gmail.com" "BillBobington@yahoo.com" "ChuckCooper@hotmail.com"
So in your current logic, all you would then need to do is put a reference to this macro variable in the 'to' section. When it compiles, the macro variable will resolve to the list of email addresses (now in quotations), and then execute on that logic.
Hope this helps.
Thank you for your help!
You're welcome
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: