<?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: Send EMail as soon as job fails in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657689#M197127</link>
    <description>&lt;P&gt;Apologies for the botched email syntax and glad you could solve your question.&lt;/P&gt;
&lt;P&gt;I copied without thinking from the &lt;A href="https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/038-2008.pdf" target="_self"&gt;first source I found&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 22:32:12 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-06-11T22:32:12Z</dc:date>
    <item>
      <title>Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657390#M196987</link>
      <description>&lt;P&gt;i want to send a mail as soon as it gets error on condition below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;if nobs&amp;gt;0 then&lt;BR /&gt;do;&lt;BR /&gt;put 'ERROR: No of observations that need to be corrected are ' nobs ;&lt;BR /&gt;abort abend;&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Mail should be sent out as nobs "need to be corrected based on test.xlsx file".&lt;/P&gt;&lt;P&gt;Can anyone help me with this&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 09:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657390#M196987</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2020-06-11T09:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657397#M196988</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190967"&gt;@Son_Of_Krypton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i want to send a mail as soon as it gets error on condition below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;if nobs&amp;gt;0 then&lt;BR /&gt;do;&lt;BR /&gt;put 'ERROR: No of observations that need to be corrected are ' nobs ;&lt;BR /&gt;abort abend;&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;/P&gt;
&lt;P&gt;set test;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Mail should be sent out as nobs "need to be corrected based on test.xlsx file".&lt;/P&gt;
&lt;P&gt;Can anyone help me with this&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;nobs will always be missing at the beginning of the data step, so your condition can never be true. Did you actually want to send the mail depending on the &lt;EM&gt;number of observations&lt;/EM&gt; in dataset test, and not on a variable called nobs in that dataset?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 09:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657397#M196988</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-11T09:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657403#M196989</link>
      <description>&lt;P&gt;scenario is like if table has more than one record then it should fail and mail should be sent.as i mentioned ignore nobs then&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 09:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657403#M196989</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2020-06-11T09:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657422#M196990</link>
      <description>&lt;P&gt;Then you need the NOBS= option in the SET statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
if nobs &amp;gt; 1
then do;
  put 'ERROR: No of observations that need to be corrected are ' nobs ;
  abort abend;
end;
stop;
set test nobs=nobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jun 2020 10:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657422#M196990</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-11T10:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657432#M196995</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename EMAIL email;
data_null_;
  if 0 then set TABLE nobs=NOBS;
  if NOBS&amp;gt;1 then do;
    file MAIL to      = 'user@company.com'
              subject = 'Error Mail message';
    put "Hello";
    put "We have a problem";  
  end;
  stop;
run;
&lt;/CODE&gt;&lt;/PRE&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;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 11:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657432#M196995</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-11T11:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657439#M196998</link>
      <description>&lt;P&gt;program also need to be aborted&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 11:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657439#M196998</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2020-06-11T11:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657444#M197002</link>
      <description>&lt;P&gt;Surely you can add that.&lt;/P&gt;
&lt;P&gt;And the proper email content.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 11:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657444#M197002</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-11T11:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657489#M197020</link>
      <description>&lt;P&gt;I am getting below error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename EMAIL email;&lt;/P&gt;&lt;P&gt;data&amp;nbsp; _null_;&lt;BR /&gt;3834 if 0 then set TEST nobs=NOBS;&lt;BR /&gt;3835 if NOBS&amp;gt;1 then do;&lt;BR /&gt;3836 file MAIL to = 'user@company.com'&lt;BR /&gt;^&lt;BR /&gt;ERROR: Option "to" is not known for FILE&lt;BR /&gt;3837 subject = 'Error Mail message';&lt;BR /&gt;3838 put "Hello";&lt;BR /&gt;3839 put "We have a problem";&lt;BR /&gt;3840 put "Error: Records not matching" ;&lt;BR /&gt;3841 end;&lt;BR /&gt;3842 stop;&lt;BR /&gt;3843 run;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 12:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657489#M197020</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2020-06-11T12:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657502#M197026</link>
      <description>&lt;P&gt;Specify the EMAIL file reference in a separate&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=n0ig2krarrz6vtn1aw9zzvtez4qo.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;FILENAME Statement, EMAIL (SMTP) Access Method&lt;/A&gt;, and study the documentation I linked to.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 13:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657502#M197026</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-11T13:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Send EMail as soon as job fails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657689#M197127</link>
      <description>&lt;P&gt;Apologies for the botched email syntax and glad you could solve your question.&lt;/P&gt;
&lt;P&gt;I copied without thinking from the &lt;A href="https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/038-2008.pdf" target="_self"&gt;first source I found&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 22:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-EMail-as-soon-as-job-fails/m-p/657689#M197127</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-11T22:32:12Z</dc:date>
    </item>
  </channel>
</rss>

