Is there a way to make SAS stop upon the first warning or error?

sas
Two Bit Gangster picture Two Bit Gangster · Jan 25, 2012 · Viewed 23.2k times · Source

SAS likes to continue processing well after warnings and errors, so I often need to scroll back through pages in the log to find an issue. Is there a better way? I'd like it to stop as soon as the first error or warning appears so I can fix it and try again.

Answer

RWill picture RWill · Jan 26, 2012

The ERRORS=1 option was previously suggested, but that only stops he ERROR messages from writing to the log. I would suggest another system option ERRORABEND which will stop the program from further processing for most errors. I don't know of an option to terminate processing due to warnings, but I think that you could add a macro like the following to stop processing.

%macro check_for_errors;
   %if &syserr > 0 %then %do;
      endsas;
   %end;
%mend check_for_errors;

data test1;
    <data step code>
run;
%check_for_errors;

You could repeat the macro call after each step of your program, and it should terminate at the point that the error code is anything but 0.