<?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: Error Notification in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-Notification/m-p/704219#M215865</link>
    <description>&lt;P&gt;What does the code look like immediately before you call the Send_mail macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suspect something else is called that is resetting your &amp;amp;syscc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It has been a long time since I have used the error codes but found it useful to copy the macro variable values to a specific macro variable at each point it was likely to be an error. Then I had a list of macro variables and showed status of all the steps not just the job overall (last step that sets the macro value)&lt;/P&gt;</description>
    <pubDate>Mon, 07 Dec 2020 17:44:48 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-12-07T17:44:48Z</dc:date>
    <item>
      <title>Error Notification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Notification/m-p/704143#M215837</link>
      <description>&lt;P&gt;I have code in one of my cron jobs to send a notification to my email of any errors during the morning execution.&lt;/P&gt;
&lt;P&gt;If the program ran without errors, I send a message that it completed.&amp;nbsp; If not, it lists the completion code.&lt;/P&gt;
&lt;P&gt;Yesterday's run did contain an ERROR due to an empty table during a SQL step.&amp;nbsp; However, my code did not capture this error?&amp;nbsp; Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Current code:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;%macro send_mail;&lt;BR /&gt;filename mymail email '&amp;lt;email address&amp;gt;' subject='STATUS Code in CRON job';&lt;BR /&gt;%if &amp;amp;syscc&amp;gt;0 %then %do;&lt;BR /&gt;data _null_;&lt;BR /&gt;file mymail;&lt;BR /&gt;put "Checking on the STATUS CODE of the daily cron jobs on &amp;amp;sysdate. at &amp;amp;systime.";&lt;BR /&gt;put "STATUS code = &amp;amp;syscc. 0=success, 4=warning";&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;data _null_;&lt;BR /&gt;file mymail;&lt;BR /&gt;put 'The job ran to completion';&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%send_mail&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Error in log yesterday that my code did not pick up:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;ERROR: Table &amp;lt;LIBNAME.TABLE_NAME&amp;gt; doesn't have any columns. PROC SQL requires each of its tables to have at least 1 column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 14:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Notification/m-p/704143#M215837</guid>
      <dc:creator>Linda_V</dc:creator>
      <dc:date>2020-12-07T14:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error Notification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Notification/m-p/704158#M215843</link>
      <description>&lt;P&gt;There is something else at work here.&lt;/P&gt;
&lt;P&gt;See this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let syscc=0;

data class;
set sashelp.class;
drop _all_;
run;

proc sql;
select * from class;
quit;

%put &amp;amp;syscc;

%if &amp;amp;syscc&amp;gt;0 %then %do;
%put "error detected";
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which causes your ERROR message. SYSCC is set to 1012, and that is detected in a %IF:&lt;/P&gt;
&lt;PRE&gt; 73         %let syscc=0;
 74         
 75         data class;
 76         set sashelp.class;
 77         drop _all_;
 78         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.CLASS has 19 observations and 0 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 79         
 80         proc sql;
 81         select * from class;
 ERROR: Table WORK.CLASS doesn't have any columns. PROC SQL requires each of its tables to have at least 1 column.
 NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
 82         quit;
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE:  Verwendet wurde: PROZEDUR SQL - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 83         
 84         %put &amp;amp;syscc;
 1012
 85         
 86         %if &amp;amp;syscc&amp;gt;0 %then %do;
 87         %put "error detected";
 "error detected"
 88         %end;
 89         
&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2020 15:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Notification/m-p/704158#M215843</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-07T15:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error Notification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Notification/m-p/704219#M215865</link>
      <description>&lt;P&gt;What does the code look like immediately before you call the Send_mail macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suspect something else is called that is resetting your &amp;amp;syscc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It has been a long time since I have used the error codes but found it useful to copy the macro variable values to a specific macro variable at each point it was likely to be an error. Then I had a list of macro variables and showed status of all the steps not just the job overall (last step that sets the macro value)&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 17:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Notification/m-p/704219#M215865</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-07T17:44:48Z</dc:date>
    </item>
  </channel>
</rss>

