<?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 &amp;amp;syserr in proc export in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270533#M18754</link>
    <description>&lt;P&gt;I have an error handling. The macro %errmail from a documentation of sas with option nonsyntaxcheck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;filename myfile email
to=&amp;amp;e_mail.
subject= "Error: &amp;amp;number."
type="text/plain";
%macro errmail;
%if &amp;amp;syserr ne 0 %then %do;
options obs= max replace nosyntaxcheck;
data _null_;
file myfile;
put;
put 'ERROR';
put "&amp;amp;syserrortext";
put 'check a log'
run;
%abort cancel;
%end;
%mend errmail;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;when I have the error in the proc export: (&amp;amp;number. is the table in the work)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc export data=&amp;amp;number.
outfile="/usr/local/backup/&amp;amp;number./&amp;amp;number._%SYSFUNC(TODAY(),DATE9.).txt"
replace
dbms=dlm;
delimiter=';';
run;
%errmail;
ERROR: Physical file does not exist, /usr/local/backup/2116/2116_13MAY2016.txt.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.2116.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;But for proc import and proc export &amp;amp;syserr is 0 despite&amp;nbsp;errors, so macro is usless here for me.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I need an e-mail about that and I want that SAS stops processing because of macro. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can I fix it?&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;</description>
    <pubDate>Sun, 15 May 2016 12:00:37 GMT</pubDate>
    <dc:creator>aola</dc:creator>
    <dc:date>2016-05-15T12:00:37Z</dc:date>
    <item>
      <title>&amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270533#M18754</link>
      <description>&lt;P&gt;I have an error handling. The macro %errmail from a documentation of sas with option nonsyntaxcheck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;filename myfile email
to=&amp;amp;e_mail.
subject= "Error: &amp;amp;number."
type="text/plain";
%macro errmail;
%if &amp;amp;syserr ne 0 %then %do;
options obs= max replace nosyntaxcheck;
data _null_;
file myfile;
put;
put 'ERROR';
put "&amp;amp;syserrortext";
put 'check a log'
run;
%abort cancel;
%end;
%mend errmail;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;when I have the error in the proc export: (&amp;amp;number. is the table in the work)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc export data=&amp;amp;number.
outfile="/usr/local/backup/&amp;amp;number./&amp;amp;number._%SYSFUNC(TODAY(),DATE9.).txt"
replace
dbms=dlm;
delimiter=';';
run;
%errmail;
ERROR: Physical file does not exist, /usr/local/backup/2116/2116_13MAY2016.txt.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.2116.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;But for proc import and proc export &amp;amp;syserr is 0 despite&amp;nbsp;errors, so macro is usless here for me.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I need an e-mail about that and I want that SAS stops processing because of macro. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can I fix it?&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;</description>
      <pubDate>Sun, 15 May 2016 12:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270533#M18754</guid>
      <dc:creator>aola</dc:creator>
      <dc:date>2016-05-15T12:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270546#M18756</link>
      <description>&lt;P&gt;Check what the value of the error variable is right after the proc. If it's being calculated properly, then change your macro to take a paramter&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=&amp;amp;number.
outfile="/usr/local/backup/&amp;amp;number./&amp;amp;number._%SYSFUNC(TODAY(),DATE9.).txt"
replace
dbms=dlm;
delimiter=';';
run;

%let error_var = &amp;amp;syserr;

%put &amp;amp;error_var;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 May 2016 21:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270546#M18756</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-14T21:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270558#M18757</link>
      <description>&lt;PRE&gt;
Maybe you could try another macro variable ?

%put &amp;amp;syserrortext ;
&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 May 2016 02:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270558#M18757</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-15T02:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270579#M18758</link>
      <description>&lt;P&gt;&lt;SPAN class="comment-copy"&gt;Sholud I change &lt;CODE&gt;&amp;amp;syserr ne 0&lt;/CODE&gt;? for syserrortext? But if &amp;amp;syserr=0 for proc export why SAS stops although I have the nosyntaxcheck option?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2016 13:23:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270579#M18758</guid>
      <dc:creator>aola</dc:creator>
      <dc:date>2016-05-15T13:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270582#M18759</link>
      <description>&lt;P&gt;Please note that, according to the &lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl/en/mcrolref/67912/HTML/default/n1wrevo4roqsnxn1fbd9yezxvv9k.htm" target="_blank"&gt;documentation&lt;/A&gt;, SYSERR "[c]ontains a return code status set by some SAS procedures and the DATA step." Apparently, this does not include &lt;EM&gt;all&lt;/EM&gt; SAS procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not surprising that SYSERR does not work well with PROC EXPORT, because this procedure is very special: As you can see in the log of a PROC EXPORT step, this procedure in fact executes a &lt;EM&gt;data step&lt;/EM&gt;. This data step produces the error message "Physical file does not exist ..." and it sets SYSERR to a value &amp;gt;0 (on my computer the return code is 1012). However, immediately after this the actual PROC step continues and it writes messages of the following form to the log:&lt;/P&gt;
&lt;PRE&gt;0 records created in ....txt from ...

NOTE: "....txt" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
...&lt;/PRE&gt;
&lt;P&gt;The note "... successfully created"&amp;nbsp;is questionable, but apparently SAS regards the PROC step as successful, which implies that SYSERR is reset to 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you should use other automatic macro variables, as also Ksharp has suggested. SYSERRORTEXT is a good candidate, because it is &lt;EM&gt;not&lt;/EM&gt; reset after a successful step. In your example it will still contain the error message "Physical file does not exist ...". Another one is &lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl/en/mcrolref/67912/HTML/default/p11nt7mv7k9hl4n1x9zwkralgq1b.htm" target="_blank"&gt;SYSCC&lt;/A&gt;.&amp;nbsp;In my test it still contains the error code 1012 from the unsuccessful data step (executed&amp;nbsp;by PROC EXPORT).&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2016 11:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270582#M18759</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-15T11:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270586#M18760</link>
      <description>&lt;P&gt;So I understand I can replace syserr to syscc in the macro %errmail.&lt;BR /&gt;What really difference between syscc and syserrortext otherwise the syserrortext is the text of the last error. Is it important which one I use?&amp;nbsp;&lt;BR /&gt;I just wondering because most error handlings what I found based on &amp;amp;syserr. Why if e.g. proc export and proc import have some issues setting &amp;amp;SYSERR properly?&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2016 13:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270586#M18760</guid>
      <dc:creator>aola</dc:creator>
      <dc:date>2016-05-15T13:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270587#M18761</link>
      <description>&lt;P&gt;The value of SYSCC reflects the status of the current SAS session. For more details, please see the documentation I linked to in my previous post, in particular for the impact of the ERRORCHECK=&amp;nbsp;system option on SYSCC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally, I prefer error handling techniques which strive to avoid error or warning messages issued by SAS as far as possible and instead perform checks &lt;EM&gt;before&lt;/EM&gt; an error occurs. Simple example: Do not&amp;nbsp;divide y by z and &lt;EM&gt;then&lt;/EM&gt; check if some message about "division by zero" has occurred. Instead, check &lt;EM&gt;first&lt;/EM&gt; if z=0 or either operand is missing and if this is the case, &lt;EM&gt;take&amp;nbsp;different action.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your example,&amp;nbsp;the error message "Physical file does not exist ..." could be avoided in most cases by checking the existence of that file (or directory) using the &lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl//en/lefunctionsref/67960/HTML/default/n06xm8hwk0t0axn10gj16lfiri43.htm" target="_blank"&gt;FILEEXIST function&lt;/A&gt;. If the file or directory does not exist, you can do whatever you deem appropriate in this situation: definitely skip the PROC EXPORT step, maybe exit the program or write a &lt;EM&gt;user-defined&lt;/EM&gt; message to the log, send an email, ...&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2016 14:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270587#M18761</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-15T14:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270609#M18762</link>
      <description>&lt;P&gt;My opinion is that this is a bug and SYSERR should be set as it would be if this were a user-written DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use SAS batch processing a lot and I rely on the job return code being non-zero if there is an error somewhere in the job. This also causes the batch job to go into syntax check mode and avoid creating any suspect data. With this PROC EXPORT or IMPORT bug (same problem with IMPORT) you cannot rely on the job return code to tell if it is successful or not. You have to go searching through the log to see if any IMPORT/EXPORT step failed. OK you could add your own error checking but you shouldn't have to in this case. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2016 20:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270609#M18762</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-05-15T20:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270638#M18763</link>
      <description>&lt;P&gt;If I use %syserrortext&amp;nbsp;I suppose&lt;/P&gt;&lt;PRE&gt; %abort cancel; &lt;/PRE&gt;&lt;P&gt;overrides me an error that interests me.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%if %length(&amp;amp;syserrortext) ne 0 %then %do;  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;can I get the penultimate &amp;amp;syserrortext?&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 08:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270638#M18763</guid>
      <dc:creator>aola</dc:creator>
      <dc:date>2016-05-16T08:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270648#M18765</link>
      <description>You can use %return;  instead of %abort;</description>
      <pubDate>Mon, 16 May 2016 08:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270648#M18765</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-16T08:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270655#M18768</link>
      <description>&lt;P&gt;but now I got a few e-mails with one error because sas dont stop&amp;nbsp;and goes further:(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro errmail;                                                                                                                         
 %if %length(&amp;amp;syserrortext) ne 0 %then %do;  
options obs=max noreplace nosyntaxcheck; 

  data _null_;        
   file myfile;                                                                                                                                                                                               
   put;                                                                                                                                 
   put 'ERROR';                                                                                                                    
   put "&amp;amp;syserrortext";                                                                                                                 
   put;
	put "Log: \logs" ;
  run;       
 %end;   
 %return cancel; 
%mend errmail;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 09:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270655#M18768</guid>
      <dc:creator>aola</dc:creator>
      <dc:date>2016-05-16T09:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270656#M18769</link>
      <description>&lt;PRE&gt;%return cancel; &lt;/PRE&gt;
&lt;P&gt;--&amp;gt;&lt;/P&gt;
&lt;PRE&gt;%return; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I noticed you should include %return into %do; %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let flag=1;

%macro xxx;
%if &amp;amp;flag=1 %then %do;
 
 %return ;
%end;
%else %do;
 %put NOTE: flag=&amp;amp;flag;
%end;
%mend;


%xxx&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR, don't use %return; or %abort; , just data step code ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro errmail;                                                                                                                         
 %if %length(&amp;amp;syserrortext) ne 0 %then %do;
  
options obs=max noreplace nosyntaxcheck; 
  data _null_;        
   file myfile;                                                                                                                                                                                               
   put;                                                                                                                                 
   put 'ERROR';                                                                                                                    
   put "&amp;amp;syserrortext";                                                                                                                 
   put;
	put "Log: \logs" ;
  run;       
 %end;   

%mend errmail;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 09:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270656#M18769</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-16T09:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: &amp;syserr in proc export</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270674#M18775</link>
      <description>&lt;PRE&gt;
Or maybe you run some dummy code to reset &amp;amp;syserrortext . Like :



%macro errmail;                                                                                                                         
 %if %length(&amp;amp;syserrortext) ne 0 %then %do;
  
options obs=max noreplace nosyntaxcheck; 
  data _null_;        
   file myfile;                                                                                                                                                                                               
   put;                                                                                                                                 
   put 'ERROR';                                                                                                                    
   put "&amp;amp;syserrortext";                                                                                                                 
   put;
	put "Log: \logs" ;
  run;       
 %end;   

%mend errmail;




data _null_;
 set sashelp.class;
run;
proc print data=sashelp.class;run;

%errmail

&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 12:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/amp-syserr-in-proc-export/m-p/270674#M18775</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-16T12:09:35Z</dc:date>
    </item>
  </channel>
</rss>

