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='raymondb_test@test.co.za'
sender='raymondb_test@test.co.za'
replyto='raymondb_test@test.co.za'

%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.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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