<?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 run different macros dependant on comination of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441042#M110276</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a program in SAS EG that runs different macros dependant on different variables ... the results should be emails going to different addresses&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the basic structure is&lt;/P&gt;
&lt;P&gt;-a series of macro variables using %LET&lt;/P&gt;
&lt;P&gt;-then the definition of each macro - FROM, TO, SUBJECT etc .. for each email&lt;/P&gt;
&lt;P&gt;-then the following datastep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It all works and brings up no errors - EXCEPT that it always uses the last macro written&amp;nbsp;%email7 .... or if I change the last one to be %email1 for example it will run that, even if the conditions match a different macro.&amp;nbsp; I have tried various different approaches but this is the only one that doesn't error. Can you let me know how I can achieve this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sendemail;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'R'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'U'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email1&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'S'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email2&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'S'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email3&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'P'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email4&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'P'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email5&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email6&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email7&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2018 21:53:08 GMT</pubDate>
    <dc:creator>franph</dc:creator>
    <dc:date>2018-02-28T21:53:08Z</dc:date>
    <item>
      <title>How do I run different macros dependant on comination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441042#M110276</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a program in SAS EG that runs different macros dependant on different variables ... the results should be emails going to different addresses&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the basic structure is&lt;/P&gt;
&lt;P&gt;-a series of macro variables using %LET&lt;/P&gt;
&lt;P&gt;-then the definition of each macro - FROM, TO, SUBJECT etc .. for each email&lt;/P&gt;
&lt;P&gt;-then the following datastep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It all works and brings up no errors - EXCEPT that it always uses the last macro written&amp;nbsp;%email7 .... or if I change the last one to be %email1 for example it will run that, even if the conditions match a different macro.&amp;nbsp; I have tried various different approaches but this is the only one that doesn't error. Can you let me know how I can achieve this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sendemail;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'R'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'U'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email1&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'S'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email2&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'S'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email3&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'P'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email4&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'P'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email5&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email6&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;or&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email7&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 21:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441042#M110276</guid>
      <dc:creator>franph</dc:creator>
      <dc:date>2018-02-28T21:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run different macros dependant on comination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441048#M110277</link>
      <description>&lt;P&gt;One obvious glaring error is that when you have&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you also need to have an&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 22:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441048#M110277</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-02-28T22:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run different macros dependant on comination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441081#M110285</link>
      <description>&lt;P&gt;Hi Paige&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I put end after each 'then do'&amp;nbsp; I get the following error 7 times, 1 for each 'then do'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;330 end;&lt;/P&gt;
&lt;P&gt;___&lt;/P&gt;
&lt;P&gt;161&lt;/P&gt;
&lt;P&gt;ERROR 161-185: No matching DO/SELECT statement.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I just put end after the last 'do then'&amp;nbsp; (for %email7) I get&amp;nbsp;the same error, but only once&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;could you perhaps show me what you mean ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 00:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441081#M110285</guid>
      <dc:creator>franph</dc:creator>
      <dc:date>2018-03-01T00:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run different macros dependant on comination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441098#M110296</link>
      <description>&lt;P&gt;I don't think macros are conditional, ie it will run all regardless of where it is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
if (&amp;amp;Customer_Segment in ('U', 'R') ) then do;
 
%email1 ;
end;
　
else if (&amp;amp;Customer_Segment='S' and &amp;amp;Manager_Status= 'Managed') then do;
 
%email2 ;
end;
　
else if (&amp;amp;Customer_Segment='S' and (&amp;amp;Manager_Status in ('Vacant' , 'Unmanaged')) then do;
 
%email3 ;
end;
　&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think you need to call the macro with call execute instead. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
if (&amp;amp;Customer_Segment in ('R' , 'U') ) then call execute('%email1;');　
else if (&amp;amp;Customer_Segment='S' and &amp;amp;Manager_Status= 'Managed') then call execute('%email2;') ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have some other logical issues in your code that isn't valid, so you need to revise those to use IN as above.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(&amp;amp;Manager_Status= ('Vacant' or 'Unmanaged')))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would suggest doing one or two at a time and then adding in the IF statements iteratively to ensure it works as designed. I'm also assuming that the %email macros don't need any data from the input data set. If it does, this process needs to be revised.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's also an argument for putting Manager_Status and Customer Segment into the macro parameters and moving all of this logic into your %email macro instead. It would make it more manageable I suspect, since your %email macro will contain all the logic for the emailing in one place where it's now split into multiple macros/programs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35723"&gt;@franph&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a program in SAS EG that runs different macros dependant on different variables ... the results should be emails going to different addresses&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the basic structure is&lt;/P&gt;
&lt;P&gt;-a series of macro variables using %LET&lt;/P&gt;
&lt;P&gt;-then the definition of each macro - FROM, TO, SUBJECT etc .. for each email&lt;/P&gt;
&lt;P&gt;-then the following datastep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It all works and brings up no errors - EXCEPT that it always uses the last macro written&amp;nbsp;%email7 .... or if I change the last one to be %email1 for example it will run that, even if the conditions match a different macro.&amp;nbsp; I have tried various different approaches but this is the only one that doesn't error. Can you let me know how I can achieve this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sendemail;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'R'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;or&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'U'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email1&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'S'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email2&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'S'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;or&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email3&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'P'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email4&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'P'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;or&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email5&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'C'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Manager_Status= &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Managed'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email6&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Customer_Segment=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'C'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&amp;amp;Manager_Status= (&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Vacant'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;or&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'Unmanaged'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;))) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;email7&lt;/I&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&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;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 02:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441098#M110296</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-01T02:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run different macros dependant on comination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441138#M110310</link>
      <description>&lt;P&gt;What are your macros like? Do they contain datastep code, which can be run inside the datastep? If not, you will have to call them in a different way. For instance using call execute, e.g.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (&amp;amp;Customer_Segment='R' or &amp;amp;Customer_Segment='U') then
  call execute('%email1 ;');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Mar 2018 08:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-run-different-macros-dependant-on-comination-of/m-p/441138#M110310</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-03-01T08:44:38Z</dc:date>
    </item>
  </channel>
</rss>

