<?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 How do I SAS email to different addresses depending on criteria ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-SAS-email-to-different-addresses-depending-on-criteria/m-p/437400#M108897</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS EG / Base SAS &amp;amp; &amp;nbsp;trying to send emails to different recipients depending on certain criteria,&amp;nbsp; I have this bock of code within the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;if (&amp;amp;Customer_Segment='R' or 'U') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("YYY@company.co.nz") 
subject= "TEST email 1" ;end;


if (&amp;amp;Customer_Segment='S') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("ZZZ@company.co.nz") 
subject= "TEST email 2" ;end;


if (&amp;amp;Customer_Segment='C' or 'P') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("QQQ@company.co.nz") 
subject= "TEST email 3" ;end;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Customer_Segment is defined further down in the program for each email to be sent , e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;%S_Letter (Letter_No='L02',
Customer_No='1234567890',
Account_No='nnnnnnnnnnnnnnnn001',
Customer_Segment='R',		 
Staff_No=222222,
Manager_Status='Vacant',   
Customer_Name='Donald Duck',  ;		



%S_Letter (Letter_No='L05',
Customer_No='1234567890',
Account_No='nnnnnnnnnnnnnnnn001',
Customer_Segment='S',		 
Staff_No=222222,
Manager_Status='Managed',   
Customer_Name='Mickey Mouse',  ;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is that no matter what the Customer_Segment is it always sends every email to the last&amp;nbsp; address etc. as if no other variations have been coded .... so in the above example&amp;nbsp;the letter to Donald Duck&amp;nbsp;- Customer Segment 'R'&amp;nbsp; ... would get sent to QQQ@company.co.nz with subject line 'TEST email 3' .... instead of YYY@company.co.nz with subject line 'TEST email 1'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any help much appreciated !&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2018 02:17:53 GMT</pubDate>
    <dc:creator>franph</dc:creator>
    <dc:date>2018-02-15T02:17:53Z</dc:date>
    <item>
      <title>How do I SAS email to different addresses depending on criteria ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-SAS-email-to-different-addresses-depending-on-criteria/m-p/437400#M108897</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS EG / Base SAS &amp;amp; &amp;nbsp;trying to send emails to different recipients depending on certain criteria,&amp;nbsp; I have this bock of code within the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;if (&amp;amp;Customer_Segment='R' or 'U') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("YYY@company.co.nz") 
subject= "TEST email 1" ;end;


if (&amp;amp;Customer_Segment='S') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("ZZZ@company.co.nz") 
subject= "TEST email 2" ;end;


if (&amp;amp;Customer_Segment='C' or 'P') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("QQQ@company.co.nz") 
subject= "TEST email 3" ;end;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Customer_Segment is defined further down in the program for each email to be sent , e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;%S_Letter (Letter_No='L02',
Customer_No='1234567890',
Account_No='nnnnnnnnnnnnnnnn001',
Customer_Segment='R',		 
Staff_No=222222,
Manager_Status='Vacant',   
Customer_Name='Donald Duck',  ;		



%S_Letter (Letter_No='L05',
Customer_No='1234567890',
Account_No='nnnnnnnnnnnnnnnn001',
Customer_Segment='S',		 
Staff_No=222222,
Manager_Status='Managed',   
Customer_Name='Mickey Mouse',  ;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is that no matter what the Customer_Segment is it always sends every email to the last&amp;nbsp; address etc. as if no other variations have been coded .... so in the above example&amp;nbsp;the letter to Donald Duck&amp;nbsp;- Customer Segment 'R'&amp;nbsp; ... would get sent to QQQ@company.co.nz with subject line 'TEST email 3' .... instead of YYY@company.co.nz with subject line 'TEST email 1'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any help much appreciated !&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 02:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-SAS-email-to-different-addresses-depending-on-criteria/m-p/437400#M108897</guid>
      <dc:creator>franph</dc:creator>
      <dc:date>2018-02-15T02:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I SAS email to different addresses depending on criteria ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-SAS-email-to-different-addresses-depending-on-criteria/m-p/437410#M108901</link>
      <description>&lt;P&gt;Make a table with that information instead, even if you're creating it from a CARDS statement. Then build your&amp;nbsp;recipient list from that table and feed that to your email program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think file statements are conditional though, so you may need to make those macro %IF/%THEN or use a different method to create the file reference. There may be a function for that...&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 03:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-SAS-email-to-different-addresses-depending-on-criteria/m-p/437410#M108901</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-15T03:16:49Z</dc:date>
    </item>
  </channel>
</rss>

