<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Automatic Emails from SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/334700#M75601</link>
    <description>I was doing some research this morning - wanted to make another thread available - from 2010 (!)&lt;BR /&gt;if I can just find it to compare that code with what domi seems to have come up with.</description>
    <pubDate>Tue, 21 Feb 2017 16:28:14 GMT</pubDate>
    <dc:creator>ccaulkins91</dc:creator>
    <dc:date>2017-02-21T16:28:14Z</dc:date>
    <item>
      <title>Automatic Emails from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/325085#M72262</link>
      <description>&lt;P&gt;Hi, I am trying to create emails based on a distribution list that I have. I cannot get it to work! I have a work.distributionlist dataset with three columns: one with email addresses one with the report that the end user receives and one autonumber column. I would like to send an email that says " "emailaddress1" you receive "report1" " with the email address and report autopopulated by the dataset file. I need it to then loop and send the same email to emailaddress2 and emailaddress3, etc... I tried creating a macro, but I'm not very good at this and can't figure out how to do it. Help would be appreciated! Here's my code so far (I'm in SAS 9.4):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create macro for looping; 
%macro createdistro_lists; 
%do autonumber = 1 %to 5; 
%global email&amp;amp;autonumber.var; 
%global report&amp;amp;autonumber.var; 
*store distribution lists to a variable; 
proc sql noprint; select trimn(email_address) into: email&amp;amp;autonumber.var from work.distribution_list; 
run; 
proc sql noprint; select trimn(report_received) into: report&amp;amp;autonumber.var from work.distribution_list; 
run; 
%put email&amp;amp;autonumber. = &amp;amp;&amp;amp;main&amp;amp;autonumber._var; 
%put report&amp;amp;autonumber. = &amp;amp;&amp;amp;report_&amp;amp;autonumber._var; 
%end; 
%mend; %create_distro_lists;
*Send emails; 
filename sendmail email; data null; 
file sendmail to=("&amp;amp;email&amp;amp;autonumber.") 
PUT "Hello"; put ' '; 
put " We have noted that you receive the following reports. 
Please confirm that this report is still in use. 
Unused reports will be retired."; 
put ' '; PUT "&amp;amp;report&amp;amp;autonumber."; 
PUT " "; PUT "Regards,";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jan 2017 17:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/325085#M72262</guid>
      <dc:creator>domigeek</dc:creator>
      <dc:date>2017-01-16T17:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Emails from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/325087#M72263</link>
      <description>&lt;P&gt;The e-mail list should contain quoted e-mail addresses, separated by spaces. &amp;nbsp;Use the CAT function (or similar) to build the components of the list in SQL. &amp;nbsp;Here's what I use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dl "/u/myid/distlist.csv";
data distlist;
  infile dl dsd;
  length email $ 50;
  input email;
run;

proc sql noprint;
select cat('"',trim(email),'"') into :toList separated by ' ' from distlist;
quit;

FILENAME OUTPUT EMAIL
 SUBJECT = "Super message"
 FROM = "sender &amp;lt;myemail@company.com&amp;gt;"
 TO = (&amp;amp;toList)
   ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jan 2017 17:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/325087#M72263</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-01-16T17:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Emails from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/325105#M72268</link>
      <description>&lt;P&gt;Thanks for your response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I have with this is that I want to take the emails from a table that's alreay in SAS and I want to send 1 email per email_address with the name of their report in the message body. There are 200 some-odd email addresses so I should have that same number of emails with different report names in the email body.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 19:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/325105#M72268</guid>
      <dc:creator>domigeek</dc:creator>
      <dc:date>2017-01-16T19:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Emails from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/327763#M73134</link>
      <description>&lt;P&gt;So I figured it out and wanted to post for others:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create last record variable;
proc sql; 
select trim( put( count(*), 3.) ) 
into : number_of_records
from work.distribution_list;
run;

*Create email variables;
proc sql; 
select email_address 
into :emails_1-:emails_&amp;amp;number_of_records.
from work.distribution_list;
run;
 
*Create report variables;
proc sql; 
select reports_received 
into :reports_received_1-:reports_received_&amp;amp;number_of_records.
from work.distribution_list;
run;

/*when you run this macro all your emails will get generated. change the '4' below to &amp;amp;number_of_records. when you are ready to run it all!*/
%macro sendEmails;
%do counter = 1 %to 4;  

filename sendmail email;
data _null_;
	
file sendmail
to=("&amp;amp;&amp;amp;emails_&amp;amp;counter.");
PUT '!em_sub! Reports Audit'; 
PUT "Hello"; PUT ' '; 
PUT " We have noted that you receive the following reports. 
Please confirm that this report is still in use. 
Unused reports will be retired."; 
PUT ' '; PUT "&amp;amp;&amp;amp;reports_received_&amp;amp;counter."; 
PUT " "; PUT "Regards,";
	%runquit; 
%end;
%mend sendEmails;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2017 16:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/327763#M73134</guid>
      <dc:creator>domigeek</dc:creator>
      <dc:date>2017-01-26T16:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Emails from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/334700#M75601</link>
      <description>I was doing some research this morning - wanted to make another thread available - from 2010 (!)&lt;BR /&gt;if I can just find it to compare that code with what domi seems to have come up with.</description>
      <pubDate>Tue, 21 Feb 2017 16:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/334700#M75601</guid>
      <dc:creator>ccaulkins91</dc:creator>
      <dc:date>2017-02-21T16:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Emails from SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/334702#M75602</link>
      <description>&lt;P&gt;And I also wanted to throw in a "shameless" plug for WRS - web report studio - and the scheduling distribution of report capabilities that have been there since 3.1. there the email lists are stored in the wrsdist library in Management Console and -&lt;/P&gt;&lt;P&gt;maybe I could write it up in the WRS community to be fair.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 16:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-Emails-from-SAS-dataset/m-p/334702#M75602</guid>
      <dc:creator>ccaulkins91</dc:creator>
      <dc:date>2017-02-21T16:31:04Z</dc:date>
    </item>
  </channel>
</rss>

