<?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: catch program failed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972398#M377491</link>
    <description>&lt;P&gt;sorry, by "failed", I mean, the launched program stops because of error.&lt;/P&gt;
&lt;PRE&gt;%macro erreur_programme;

  /* trap error here */

  %if &amp;amp;syserr^=0 %then %do;

	  %put an error occurs ;

  %end ;

  %mend erreur_programme ;

data test;
x=1 /* &amp;lt;-- intentionally leave off a semicolon to produce an error*/ 
run ;

%erreur_programme;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try this code but it does not work&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Aug 2025 09:02:08 GMT</pubDate>
    <dc:creator>Nasser_DRMCP</dc:creator>
    <dc:date>2025-08-11T09:02:08Z</dc:date>
    <item>
      <title>catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972394#M377488</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I get the information that a running program failed ?&lt;/P&gt;
&lt;P&gt;by doing that, my purpose is (for example)&amp;nbsp; to send a mail to inform&lt;/P&gt;
&lt;P&gt;thanks in advance for your help.&lt;/P&gt;
&lt;P&gt;regards&lt;/P&gt;
&lt;P&gt;Nasser&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 08:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972394#M377488</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2025-08-11T08:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972397#M377490</link>
      <description>&lt;P&gt;First, you need to clearly define "failed".&lt;/P&gt;
&lt;P&gt;For me, this was (in the first place) a return code of non-zero, which you can check from the scheduler or in-program from &amp;amp;SYSCC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 08:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972397#M377490</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-08-11T08:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972398#M377491</link>
      <description>&lt;P&gt;sorry, by "failed", I mean, the launched program stops because of error.&lt;/P&gt;
&lt;PRE&gt;%macro erreur_programme;

  /* trap error here */

  %if &amp;amp;syserr^=0 %then %do;

	  %put an error occurs ;

  %end ;

  %mend erreur_programme ;

data test;
x=1 /* &amp;lt;-- intentionally leave off a semicolon to produce an error*/ 
run ;

%erreur_programme;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try this code but it does not work&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 09:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972398#M377491</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2025-08-11T09:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972400#M377492</link>
      <description>&lt;P&gt;You could save the LOG of sas programm into a file ,and check if there are any row started with ERROR or WARNING, if there were ,put an ERROR message into a macro variable.&lt;/P&gt;
&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;PRE&gt;filename x temp;
proc printto log=x new;
run;

data x;
set sashelp.class;
array x{*} _numeric_;
y=x{10};
run;

proc printto;
run;


%let rc=the code is good ;
data _null_;
 infile x;
 input;
 if _infile_ in: ('ERROR' 'WARN') then call symputx('rc','the code is failed');
 run;

 %put &amp;amp;=rc ;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Aug 2025 09:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972400#M377492</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-11T09:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972403#M377494</link>
      <description>&lt;P&gt;Macro timing !!!&lt;/P&gt;
&lt;P&gt;Since your DATA step was never completed (the run keyword is part of the incomplete assignment statement), the macro is resolved while the data step is being compiled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the log:&lt;/P&gt;
&lt;P&gt;(run in SAS on Demand)&lt;/P&gt;
&lt;PRE&gt;81         data test;
 82         x=1 /* &amp;lt;-- intentionally leave off a semicolon to produce an error*/
 83         run ;
            ___
            22
 ERROR 22-322: Syntaxfehler, erwartet wird eines der folgenden: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, 
               IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.  
 
 84         
 85         %erreur_programme;
 86         
 87         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 WARNING: The data set WORK.TEST may be incomplete.  When this step was stopped there were 0 observations and 2 variables.
 WARNING: Datei WORK.TEST wurde nicht ersetzt, da da dieser Schritt angehalten wurde.
&lt;/PRE&gt;
&lt;P&gt;The WARNINGs coming from the DATA step appear&amp;nbsp;&lt;EM&gt;after&lt;/EM&gt; your macro call.&lt;/P&gt;
&lt;P&gt;You must make sure that a previous step has been completed, e.g. like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro erreur_programme;
;run;quit;
/* trap error here */
  %if &amp;amp;syserr^=0 %then %do;
	  %put an error occurs ;
  %end ;
%mend erreur_programme;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I still recommend to use SYSCC because of this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put SYSERR = &amp;amp;syserr.;
%put SYSCC = &amp;amp;syscc.;

data test;
x = 1
run;

;run; /* end step */

%put SYSERR = &amp;amp;syserr.;
%put SYSCC = &amp;amp;syscc.;

data test;
x = 1;
run;

%put SYSERR = &amp;amp;syserr.;
%put SYSCC = &amp;amp;syscc.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 68         
 69         %put SYSERR = &amp;amp;syserr.;
 SYSERR = 0
 70         %put SYSCC = &amp;amp;syscc.;
 SYSCC = 0
 71         
 72         data test;
 73         x = 1
 74         run;
            ___
            22
 ERROR 22-322: Syntaxfehler, erwartet wird eines der folgenden: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, 
               IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.  
 
 75         
 76         ;run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.TEST may be incomplete.  When this step was stopped there were 0 observations and 2 variables.
 WARNING: Datei WORK.TEST wurde nicht ersetzt, da da dieser Schritt angehalten wurde.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              629.90k
       OS Memory           20388.00k
       Timestamp           11.08.2025 09:43:47 vorm.
       Step Count                        47  Switch Count  0
       Page Faults                       0
       Page Reclaims                     64
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           16
       
 
 
 76       !       /* end step */
 77         
 78         %put SYSERR = &amp;amp;syserr.;
 SYSERR = 1012
 79         %put SYSCC = &amp;amp;syscc.;
 SYSCC = 1012
 80         
 81         data test;
 82         x = 1;
 83         run;
 
 NOTE: The data set WORK.TEST has 1 observations and 1 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              660.03k
       OS Memory           20388.00k
       Timestamp           11.08.2025 09:43:47 vorm.
       Step Count                        48  Switch Count  2
       Page Faults                       0
       Page Reclaims                     116
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 84         
 85         %put SYSERR = &amp;amp;syserr.;
 SYSERR = 0
 86         %put SYSCC = &amp;amp;syscc.;
 SYSCC = 1012
&lt;/PRE&gt;
&lt;P&gt;SYSERR is reset by a succeeding step, while SYSCC will keep its maximum value.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 09:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972403#M377494</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-08-11T09:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972404#M377495</link>
      <description>&lt;P&gt;thanks ksharp&lt;/P&gt;
&lt;P&gt;one more question please.&lt;/P&gt;
&lt;P&gt;is it possible to scan all log files of today in a folder (files name are like ...._20250811.log) and check each file like ?&lt;/P&gt;
&lt;P&gt;many thanks&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 09:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972404#M377495</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2025-08-11T09:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972408#M377498</link>
      <description>&lt;P&gt;There are so many ways you can do this, more or less complicated and 100% accurate, including coding in SAS, using scripting languages.&lt;/P&gt;
&lt;P&gt;There are also a lot of third party tools that manages (and parses) log files.&lt;/P&gt;
&lt;P&gt;To advise it would be helpful if you describe a little more about your operating environment nt and the IT organization.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 11:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972408#M377498</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-08-11T11:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972472#M377510</link>
      <description>&lt;P&gt;Sure. Of course.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can scan all these LOG file and output the row started with ERROR or WARN.&lt;/P&gt;
&lt;P&gt;And attach the log file name together.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path= c:\temp\log ; * the path stored LOG files;


filename x "&amp;amp;path";
data log_file;
did=dopen("x");
do i=1 to dnum(did);
 file=dread(did,i);
 if lowcase(scan(file,-1,'.'))='log' then do;
   log_file=cats("&amp;amp;path",'\',file);
   output;
 end;
end;
keep log_file;
run;

data want;
 set log_file;
 length fname filename $ 200;
 infile dummy filevar=log_file filename=fname end=last length=len;
 filename=fname;
 do while(not last);
   input log $varying200. len;
   if left(log) in: ('ERROR' 'WARN') then output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 01:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972472#M377510</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-12T01:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: catch program failed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972474#M377511</link>
      <description>&lt;P&gt;If you are OK with just email notifications from a scheduler running your programs then no addtional coding is required and you only need to setup the notifications similar to this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASKiwi_0-1754963178525.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/108959i5076A65D23DF9CFB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASKiwi_0-1754963178525.png" alt="SASKiwi_0-1754963178525.png" /&gt;&lt;/span&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 01:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catch-program-failed/m-p/972474#M377511</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-08-12T01:46:34Z</dc:date>
    </item>
  </channel>
</rss>

