<?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: Sending email with filtered excel attachments from sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/450980#M113627</link>
    <description>&lt;P&gt;Thanks Kurt for your response, I'm able to send the mail to multiple recipients now, but how should i go about filtering the column(Eg - Region) inside the excel in the program itself? Also, what if I want to send different filtered excel to different email ids?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 09:15:24 GMT</pubDate>
    <dc:creator>sklal</dc:creator>
    <dc:date>2018-04-04T09:15:24Z</dc:date>
    <item>
      <title>Sending email with filtered excel attachments from sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/450969#M113623</link>
      <description>&lt;DIV class="votecell post-layout--left"&gt;&lt;DIV class="vote"&gt;Hi all,&lt;BR /&gt;&lt;DIV class="favoritecount"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="postcell post-layout--right"&gt;&lt;DIV class="post-text"&gt;&lt;P&gt;I am required to send filtered excel attachment to different email ids from sas. For eg I have a column named region in the excel having 4 values - north,south,east, west and i have to send the northern region data to id xyz@jkl.com , southern region data to abc@jkl.com and so on. How should I go about filtering the excel via sas programming? Kindly help. Also, please suggest how to insert multiple recipients for which the filtering condition would be different.I'm attaching the code written on SAS Enterprise Guide 7.1 for single recipient which sends the unfiltered excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options emailsys = smtp
emailid = 'xxxx@gmail.com'
emailpw = 'xxxx'
emailhost = 'smtp.gmail.com'
emailport = 587 ;

options emailhost=
(
'smtp.gmail.com'
STARTTLS auth=LOGIN

id='xxxx@gmail.com'

pw='xxxx' port=587
)
;
filename f_email email
to = 'xxxx@jkl.com'
from = 'xxxx@gmail.com'
subject = 'Test'
attach=("xxxx.xlsx"  content_type="application/xlsx");

data _null_;
file f_email;
put 'Test';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;sklal&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 04 Apr 2018 08:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/450969#M113623</guid>
      <dc:creator>sklal</dc:creator>
      <dc:date>2018-04-04T08:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sending email with filtered excel attachments from sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/450974#M113626</link>
      <description>&lt;P&gt;Wrap your code into a macro and call it off a control dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro send_mail(email,attachment);

filename f_email email
to = "&amp;amp;email"
from = 'xxxx@gmail.com'
subject = 'Test'
attach=("&amp;amp;attachment"  content_type="application/xlsx");

data _null_;
file f_email;
put 'Test';
run;

%mend;

data control;
infile cards dlm=',';
input email :$30. attachment :$50.;
cards;
xxxx@jkl.com,xxxx.xlsx
;
run;

data _null_;
set control;
call execute('%send_mail(' !! trim(email) !! ',' !! trim(attachment) !! ');');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 08:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/450974#M113626</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-04T08:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sending email with filtered excel attachments from sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/450980#M113627</link>
      <description>&lt;P&gt;Thanks Kurt for your response, I'm able to send the mail to multiple recipients now, but how should i go about filtering the column(Eg - Region) inside the excel in the program itself? Also, what if I want to send different filtered excel to different email ids?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 09:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/450980#M113627</guid>
      <dc:creator>sklal</dc:creator>
      <dc:date>2018-04-04T09:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sending email with filtered excel attachments from sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/451037#M113643</link>
      <description>&lt;P&gt;Move a selecting step and the creation of the Excel (still better would be a csv) into the macro, and add a macro parameter for the condition. Add the same to the control dataset and the call execute.&lt;/P&gt;
&lt;P&gt;The list of recipients in a filename email can be separated by blanks, BTW.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 11:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/451037#M113643</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-04T11:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sending email with filtered excel attachments from sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/451054#M113654</link>
      <description>&lt;P&gt;Thanks Kurt, I think I got what you're suggesting (I'm a newbie). I'll try to implement the same.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 12:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/451054#M113654</guid>
      <dc:creator>sklal</dc:creator>
      <dc:date>2018-04-04T12:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sending email with filtered excel attachments from sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/451066#M113658</link>
      <description>&lt;P&gt;If you run into trouble, post code and log, and where the result differs from what you expected (unless you have ERRORs, which are obvious).&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 12:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-email-with-filtered-excel-attachments-from-sas/m-p/451066#M113658</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-04T12:42:10Z</dc:date>
    </item>
  </channel>
</rss>

