BookmarkSubscribeRSS Feed
Raymond_Bern
Calcite | Level 5

I am trying to write a script where I import a excel file with name, brand and EMAIL. Once I imported the file I used the following

proc sql noprint;
select EMAIL into :HAT_emails2 separated by '" "'
from work.EMAILS
where
brand ='HAT';
quit;

 

proc sql noprint;
select name into :HAT_names separated by ''
from work.EMAILS
where
brand ='HAT';
quit;

 

and then continued to do the following :

 

FILENAME Mailbox EMAIL
to= ("&HAT_emails2.")
Subject="testing this email"
from='[email protected]'
sender='[email protected]'
replyto='[email protected]'

%let email_date = %sysfunc(today(),YYMMDD10.);
%put &email_date.;

DATA _NULL_;
FILE Mailbox;

PUT "Hi &HAT_names2.";

run;

 

The problem is that the "&HAT_names2." only works for the first name on the list how do i get it to send a personalized email for each name in the list?

 

The email is sent to each email address in the import however when trying to personalize the email with each persons name in the next column (name) this only shows the first record for all the emails sent. The PUT "Hi &HAT_names2."; only shows the first name in the dataset to all the emails sent.

1 REPLY 1
ChrisHemedinger
Community Manager

See the example from my How to Send Email with SAS article. There are examples of sending one email to a list of recipients, as well as personalized emails where the content is different per recipient.

Become an Explorer! Join SAS Analytics Explorers to learn and complete challenges that earn rewards!

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 1656 views
  • 1 like
  • 2 in conversation