<?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 send an email to different mailbox base on which server I run the program on? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/send-an-email-to-different-mailbox-base-on-which-server-I-run/m-p/345295#M273109</link>
    <description>&lt;P&gt;have a program that runs and send an email but want to set it up so the macro that sent the email execute depending on the server (live or test) I am runing it on.&lt;/P&gt;&lt;P&gt;I have created 4 macros namely email,report,live_email and live_report - I call the maco %report if there is a record in the dataset else %email. The same recipient for %email and %report and another recipient for live_email and live_report.&lt;/P&gt;&lt;P&gt;currently it send the email to %report recipient irrespective or the server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* SETTING ENVIRONMENT */&lt;BR /&gt;options symbolgen mlogic;&lt;BR /&gt;%let env = %scan( &amp;amp;SYSTCPIPHOSTNAME,1,'.');&lt;/P&gt;&lt;P&gt;** *********************** LIVE ***************************************;;&lt;BR /&gt;%let live = gal;&lt;BR /&gt;%let liveRecipients = 'missjoe.blog@sch.com ';&lt;/P&gt;&lt;P&gt;************************** TEST ***************************************;;&lt;BR /&gt;%let test = guy;&lt;BR /&gt;%let testRecipients = 'joe.bloc@sch.com';&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set cont;&lt;BR /&gt;if &amp;amp;env. eq &amp;amp;test. then&lt;BR /&gt;do;&lt;BR /&gt;if nobs&amp;gt;0 then&lt;BR /&gt;call execute('%report');&lt;BR /&gt;else call execute('%email');&lt;BR /&gt;end;&lt;BR /&gt;else if &amp;amp;env. eq &amp;amp;live. then&lt;BR /&gt;do;&lt;BR /&gt;if nobs&amp;gt;0 then&lt;BR /&gt;call execute('%live_report');&lt;BR /&gt;else call execute('%live_email');&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help please!!&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2017 09:59:00 GMT</pubDate>
    <dc:creator>Agogo</dc:creator>
    <dc:date>2017-03-29T09:59:00Z</dc:date>
    <item>
      <title>send an email to different mailbox base on which server I run the program on?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-an-email-to-different-mailbox-base-on-which-server-I-run/m-p/345295#M273109</link>
      <description>&lt;P&gt;have a program that runs and send an email but want to set it up so the macro that sent the email execute depending on the server (live or test) I am runing it on.&lt;/P&gt;&lt;P&gt;I have created 4 macros namely email,report,live_email and live_report - I call the maco %report if there is a record in the dataset else %email. The same recipient for %email and %report and another recipient for live_email and live_report.&lt;/P&gt;&lt;P&gt;currently it send the email to %report recipient irrespective or the server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* SETTING ENVIRONMENT */&lt;BR /&gt;options symbolgen mlogic;&lt;BR /&gt;%let env = %scan( &amp;amp;SYSTCPIPHOSTNAME,1,'.');&lt;/P&gt;&lt;P&gt;** *********************** LIVE ***************************************;;&lt;BR /&gt;%let live = gal;&lt;BR /&gt;%let liveRecipients = 'missjoe.blog@sch.com ';&lt;/P&gt;&lt;P&gt;************************** TEST ***************************************;;&lt;BR /&gt;%let test = guy;&lt;BR /&gt;%let testRecipients = 'joe.bloc@sch.com';&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set cont;&lt;BR /&gt;if &amp;amp;env. eq &amp;amp;test. then&lt;BR /&gt;do;&lt;BR /&gt;if nobs&amp;gt;0 then&lt;BR /&gt;call execute('%report');&lt;BR /&gt;else call execute('%email');&lt;BR /&gt;end;&lt;BR /&gt;else if &amp;amp;env. eq &amp;amp;live. then&lt;BR /&gt;do;&lt;BR /&gt;if nobs&amp;gt;0 then&lt;BR /&gt;call execute('%live_report');&lt;BR /&gt;else call execute('%live_email');&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help please!!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 09:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-an-email-to-different-mailbox-base-on-which-server-I-run/m-p/345295#M273109</guid>
      <dc:creator>Agogo</dc:creator>
      <dc:date>2017-03-29T09:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: send an email to different mailbox base on which server I run the program on?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-an-email-to-different-mailbox-base-on-which-server-I-run/m-p/345552#M273110</link>
      <description>&lt;P&gt;I do something similar in many of my SAS jobs. &amp;nbsp;First a %setenv macro that determines the environment and creates settings based on live/test. &amp;nbsp;Then a single %report and %email macro (that can check the &amp;amp;env and perform the appropriate actions). &amp;nbsp;Lastly a single %runit macro which checks the nobs and runs either %report or %email. &amp;nbsp;The nobs check could be as simple as checking &amp;amp;sysnobs (or opening the data set and using the attrn function check as in the example). &amp;nbsp;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* SETTING ENVIRONMENT */
options symbolgen mlogic;
%global env Recipients;

%macro setenv;
   %if %substr(&amp;amp;SYSTCPIPHOSTNAME,1,1) = L %then %do;  /* live */
      %let env=Live;
      %let Recipients = &lt;SPAN&gt;missjoe.blog@sch.com;&lt;/SPAN&gt;
   %end;

   %else %do;  /* test */
      %let env=Test;
      %let Recipients = &lt;SPAN&gt;joe.bloc@sch.com;&lt;/SPAN&gt;
   %end;
%mend setenv;
%setenv;

%macro report;
  title "&amp;amp;env Report for &amp;amp;sysdate";
  proc print data=cont;
  run;
%mend report;

%macro email;
  filename mailbox email to=("&amp;amp;Recipients") subject="No data for env=&amp;amp;env";
  data _null_;
    file mailbox;
    put "No data available for &amp;amp;env.";
  run;
%mend email;

%macro runit;
  /* get nobs via attrn */
  data _null_;
    dsid=open('cont','I');
    nobs=attrn(dsid,'nobs');
    rc=close(dsid);
    call symput('nobs',nobs);
  run;

  %if &amp;amp;nobs &amp;gt; 0 %then %report;
  %else %email;

%mend runit;
%runit;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Mar 2017 21:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-an-email-to-different-mailbox-base-on-which-server-I-run/m-p/345552#M273110</guid>
      <dc:creator>DaveHorne</dc:creator>
      <dc:date>2017-03-29T21:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: send an email to different mailbox base on which server I run the program on?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-an-email-to-different-mailbox-base-on-which-server-I-run/m-p/345683#M273111</link>
      <description>&lt;P&gt;Thanks very much DaveHorne, just got to the office would test shortly and give you feedback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 08:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-an-email-to-different-mailbox-base-on-which-server-I-run/m-p/345683#M273111</guid>
      <dc:creator>Agogo</dc:creator>
      <dc:date>2017-03-30T08:30:56Z</dc:date>
    </item>
  </channel>
</rss>

