<?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: E-mail to multiple in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326710#M271568</link>
    <description>&lt;P&gt;Excellent, thank you.......so simple sorry I missed that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you both for your help&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 13:55:06 GMT</pubDate>
    <dc:creator>Aidan</dc:creator>
    <dc:date>2017-01-23T13:55:06Z</dc:date>
    <item>
      <title>E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326650#M271556</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a work table work.&lt;SPAN&gt;W9QRSD.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The data of which is below.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ALERT &amp;nbsp; &amp;nbsp; &amp;nbsp;EMAIL&lt;/P&gt;&lt;P&gt;76 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ME@test.ie&lt;BR /&gt;87 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;ME&lt;/SPAN&gt;@&lt;SPAN&gt;test&lt;/SPAN&gt;.ie&lt;BR /&gt;76 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; YOU@&lt;SPAN&gt;test&lt;/SPAN&gt;.ie&lt;BR /&gt;76 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;YOU&lt;/SPAN&gt;@&lt;SPAN&gt;test&lt;/SPAN&gt;.ie&lt;BR /&gt;20 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;YOU&lt;/SPAN&gt;@&lt;SPAN&gt;test&lt;/SPAN&gt;.ie&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is send the data in this table to each user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So&amp;nbsp;&lt;SPAN&gt;ME@test.ie will get a mail with the below;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ALERT &amp;nbsp; &amp;nbsp; &amp;nbsp;EMAIL&lt;/P&gt;&lt;P&gt;76 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ME@test.ie&lt;BR /&gt;87 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;ME&lt;/SPAN&gt;@&lt;SPAN&gt;test&lt;/SPAN&gt;.ie&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;YOU@test.ie will get;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;76 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; YOU@&lt;/SPAN&gt;&lt;SPAN&gt;test&lt;/SPAN&gt;&lt;SPAN&gt;.ie &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;76 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;YOU&lt;/SPAN&gt;&lt;SPAN&gt;@&lt;/SPAN&gt;&lt;SPAN&gt;test&lt;/SPAN&gt;&lt;SPAN&gt;.ie &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;20 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;YOU&lt;/SPAN&gt;&lt;SPAN&gt;@&lt;/SPAN&gt;&lt;SPAN&gt;test&lt;/SPAN&gt;&lt;SPAN&gt;.ie&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;While the below user written code is working for me, it is sending 3 e-mails for YOU@test.ie but I would just want it to be sent once.....any ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* send mail from DATA;&lt;BR /&gt;%macro mailit(DATA);&lt;/P&gt;&lt;P&gt;%let NOBS=0;&lt;BR /&gt;* get emails from DATA;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select EMAIL into :EMAIL1- from &amp;amp;DATA;&lt;BR /&gt;select count(*) into :EMAILN from &amp;amp;DATA;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;* cycle through emails;&lt;BR /&gt;%do I=1 %to &amp;amp;EMAILN;&lt;BR /&gt;&lt;BR /&gt;filename temp email to="&amp;amp;&amp;amp;&amp;amp;EMAIL&amp;amp;I"&lt;BR /&gt;type="text/html"&lt;BR /&gt;subject="TEST Daily Alert List";&lt;BR /&gt;ods html file=temp;&lt;BR /&gt;proc print data=&amp;amp;DATA;&lt;BR /&gt;var ALERT;&lt;BR /&gt;where EMAIL="&amp;amp;&amp;amp;&amp;amp;EMAIL&amp;amp;I";&lt;BR /&gt;run;&lt;BR /&gt;ods html close;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend mailit;&lt;/P&gt;&lt;P&gt;%mailit(W9QRSD);&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 09:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326650#M271556</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-01-23T09:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326658#M271557</link>
      <description>&lt;P&gt;Assuming&amp;nbsp;&lt;SPAN&gt;W9QRSD is sorted:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set w9qrsd;
  by email;
  if first.email then call execute(cats('filename tmp email to="',email,'" type="text/html" subject="Abc"'; data _null_; file temp;));
  call execute(cat('put "',strip(alert),'";'));
  if last.email then call execute(';run;');
run;
  &lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;This just does basic text, as I don't see anything there which would need html.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want however, you could still use you html print.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;proc sort data=w9qrsd out=loop nodupkey;
  by email;
run;

data _null_;
  set loop;
  call execute(cats('filename temp "',email,'"; ods html file="temp";'));
  call execute(cats('proc print data=w9qrsd; where email="',email,'"; run;'));
...
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 10:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326658#M271557</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-23T10:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326659#M271558</link>
      <description>Thanks for the quick response.....so is the code you provided sufficient to replace what I have entirely or is it to be integrated with what I have?</description>
      <pubDate>Mon, 23 Jan 2017 10:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326659#M271558</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-01-23T10:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326665#M271559</link>
      <description>&lt;P&gt;Yes, it replaces it. &amp;nbsp;If you run it, you will see in your log that the datastep generates text at each observation which gets sent to the compiler after the datastep has finished. &amp;nbsp;It will be in your log with + just like an include file. &amp;nbsp;You can create any code you want using this, and the basic principal that a datastep is a loop.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 10:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326665#M271559</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-23T10:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326667#M271560</link>
      <description>I have tired both, while compiling successfully it is not e-mailing to my e-mail address.&lt;BR /&gt;&lt;BR /&gt;proc sort data=work.W9QRSD out=loop nodupkey;&lt;BR /&gt;by EMAIL;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set loop;&lt;BR /&gt;call execute(cats('filename temp "',EMAIL,'"; ods html file="temp";'));&lt;BR /&gt;call execute(cats('proc print data=work.W9QRSD; where email="',EMAIL,'"; run;'));&lt;BR /&gt;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 23 Jan 2017 10:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326667#M271560</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-01-23T10:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326673#M271561</link>
      <description>&lt;P&gt;You are missing ods close. &amp;nbsp;Also, I was just re-interpreting the code you provided here;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;filename temp email to="&amp;amp;&amp;amp;&amp;amp;EMAIL&amp;amp;I"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;type="text/html"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;subject="TEST Daily Alert List";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ods html file=temp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc print data=&amp;amp;DATA;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var ALERT;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where EMAIL="&amp;amp;&amp;amp;&amp;amp;EMAIL&amp;amp;I";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ods html close;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So to update yours (and use the code window {i} above):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;proc sort data=work.w9qrsd out=loop nodupkey;
  by email;
run;

data _null_;
  set loop;
  call execute(cats('filename temp email to="',email,'"; ods html file="temp";'));
  call execute(cats('proc print data=work.w9qrsd; where email="',email,'"; run;'));
  call execute('ods html close;');
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 10:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326673#M271561</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-23T10:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326677#M271562</link>
      <description>Sorry, there is no e-mail being generated from the above, I have tried making a few tweaks but nothing seems to work.&lt;BR /&gt;&lt;BR /&gt;It executes without error but no e-mail</description>
      <pubDate>Mon, 23 Jan 2017 11:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326677#M271562</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-01-23T11:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326691#M271563</link>
      <description>&lt;P&gt;This works fine for me (although I can't send emails from our setup it just tells me there is no email client associated):&lt;/P&gt;
&lt;PRE&gt;proc sort data=work.w9qrsd out=loop nodupkey;
  by email;
run;

data _null_;
  set loop;
  call execute(cats('filename temp email to="',email,'"; ods html body=temp;'));
  call execute(cats('proc print data=work.w9qrsd; where email="',email,'"; run;'));
  call execute('ods html close;');
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 12:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326691#M271563</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-23T12:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326692#M271564</link>
      <description>&lt;P&gt;Thanks for your help but this doesn't send any e-mails for me.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 12:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326692#M271564</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-01-23T12:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326696#M271565</link>
      <description>&lt;P&gt;What does your log say? &amp;nbsp;You must be doing something wrong, or the code in your original post can't work either. &amp;nbsp;It is not doing anything differently.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 12:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326696#M271565</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-23T12:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326707#M271566</link>
      <description>&lt;P&gt;When I click on output tab in DI, it looks to have what I would want to see in the e-mail.&lt;/P&gt;&lt;P&gt;But no e-mail is generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you saying your code will send the e-mail or I need to use my own code to do the e-mailing, just getting a bit confused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=work.W9QRSD out=loop nodupkey;&lt;BR /&gt;by EMAIL;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set loop;&lt;BR /&gt;call execute(cats('filename temp email to="',EMAIL,'"; ods html file="temp";'));&lt;BR /&gt;call execute(cats('proc print data=work.W9QRSD; where EMAIL="',EMAIL,'"; run;'));&lt;BR /&gt;call execute('ods html close;');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 13:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326707#M271566</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-01-23T13:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326708#M271567</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For my original solution, if you want unique EMAILs modify the initial PROC SQL like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc sql noprint;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;select &lt;STRONG&gt;distinct&lt;/STRONG&gt; EMAIL into :EMAIL1- from &amp;amp;DATA;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;select count(&lt;STRONG&gt;distinct EMAIL&lt;/STRONG&gt;) into :EMAILN from &amp;amp;DATA;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;quit;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 13:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326708#M271567</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-01-23T13:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: E-mail to multiple</title>
      <link>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326710#M271568</link>
      <description>&lt;P&gt;Excellent, thank you.......so simple sorry I missed that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you both for your help&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 13:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/E-mail-to-multiple/m-p/326710#M271568</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-01-23T13:55:06Z</dc:date>
    </item>
  </channel>
</rss>

