<?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: How to use SYSERR in macro as e-mail trigger if error during query to Teradata in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570714#M160958</link>
    <description>&lt;P&gt;I was going to recommend that you check that the tables are not empty, but it sounds like you've already considered that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you call your %codeEndStatus macro after each table you query? If you're only considered about a small number of the tables being empty, you could add an additional parameter indicating that you should check the number of records. You could do this inside your %codeEndStatus macro, and set the default to false so that you don't have to change your logic for all your other jobs. Is my understanding correct?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jul 2019 19:11:48 GMT</pubDate>
    <dc:creator>noling</dc:creator>
    <dc:date>2019-07-02T19:11:48Z</dc:date>
    <item>
      <title>How to use SYSERR in macro as e-mail trigger if error during query to Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570702#M160954</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Long story short. In my company is a migration from old server to new one. Good oportunity to deepedive into old code and make some upgrades. So i try do some easy notyfication about errors during calculation and I have some problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Idea is as following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Add to every sas code scheduled on server one macro execution line&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;%codeEndStatus(e-mail title,&amp;amp;SYSERR.);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This leads to macro program&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;%macro codeEndStatus(codeName,error);
%include "&amp;amp;commonsPath./emailAuth.sas"; /*data necessary to send e-mails*/

%if &amp;amp;error. = 0 %then %do ;
OPTIONS LINESIZE=256;
FILENAME output EMAIL SUBJECT= "#OK &amp;amp;codeName. OK"
FROM= e@mail.com
TO=e@mail.com
attach=("&amp;amp;logSpace./&amp;amp;curentProgramName._&amp;amp;todayShort..log")
CT= "text/html";* Required for HTML output;

ODS HTML BODY=output STYLE=noBorder;
proc odstext;
p "Everything is fine";
run;
ODS HTML CLOSE;

%end;
%else %do;
OPTIONS LINESIZE=256;
FILENAME output EMAIL SUBJECT= "#Error &amp;amp;codeName. "
FROM= e@mail.com
TO= e@mail.com
attach=("&amp;amp;logSpace./&amp;amp;curentProgramName._&amp;amp;todayShort..log")
CT= "text/html";* Required for HTML output;

ODS HTML BODY=output STYLE=noBorder;
proc odstext;
p "Something went wrong, check log file";
run;
ODS HTML CLOSE;

%end;

%mend;&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;And. Everything is fine except this situation (most common in my work).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If errors occur during selecting data from Teradata or Hadoop dataset, from SAS point of view It`s no error. Everything fine. Naturally output file is empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, usualy empty file provide errors during next computing. But not in my case, becouse I select only recent record from Teradata and append it with existing in SAS serwer dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I looking for a solution. Maybe it`s another variable to use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First thing I invented it`s simply check number of record in new table and stop executing if it's null. But I have a lot of query to external sources in my code, so adding few lines after every query is a monkey job.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 18:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570702#M160954</guid>
      <dc:creator>NiespielakWojc</dc:creator>
      <dc:date>2019-07-02T18:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SYSERR in macro as e-mail trigger if error during query to Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570711#M160957</link>
      <description>&lt;P&gt;Have you tried using &amp;amp;syscc instead of &amp;amp;syserr?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570711#M160957</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-02T19:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SYSERR in macro as e-mail trigger if error during query to Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570714#M160958</link>
      <description>&lt;P&gt;I was going to recommend that you check that the tables are not empty, but it sounds like you've already considered that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you call your %codeEndStatus macro after each table you query? If you're only considered about a small number of the tables being empty, you could add an additional parameter indicating that you should check the number of records. You could do this inside your %codeEndStatus macro, and set the default to false so that you don't have to change your logic for all your other jobs. Is my understanding correct?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570714#M160958</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-07-02T19:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SYSERR in macro as e-mail trigger if error during query to Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570715#M160959</link>
      <description>&lt;P&gt;PS it is easier to have the scheduler react to the overall return code of a SAS program and send mails.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:12:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570715#M160959</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-02T19:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SYSERR in macro as e-mail trigger if error during query to Teradata</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570834#M161013</link>
      <description>&lt;P&gt;I call macro at the end of code. So after every query.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 06:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-SYSERR-in-macro-as-e-mail-trigger-if-error-during/m-p/570834#M161013</guid>
      <dc:creator>NiespielakWojc</dc:creator>
      <dc:date>2019-07-03T06:03:25Z</dc:date>
    </item>
  </channel>
</rss>

