Hello SAS guys,
Could somebody help me out? When running SAS program, if there is any error message showing on the log window, SAS program halt immediately. How to write code to get the result?
Thanks
The SAS option that is closest to your requirement is SYNTAXCHECK. If you put this option in an OPTIONS statement then SAS will go into syntax check mode as soon as there is an error. Your program will still run to completion but it wont do any more processing as it sets zero observations to be processed.
There is another option ERRORABEND. This will close your SAS session when an error occurs. This option is more useful for batch jobs as while execution halts, it also closes your batch session.
I'm not a fan of adding generic process checking code to programs. I would rather rely on simple SAS system options which will automatically handle any job errors in an appropriate way.
Call this simple macro before each program
%macro runquit;
; run; quit;
%if &syserr. ne 0 %then %do;
%abort cancel;
%end;
%mend runquit;
< program 1>
%runquit;
< program 2>
%runquit;
< program 3>
The SAS option that is closest to your requirement is SYNTAXCHECK. If you put this option in an OPTIONS statement then SAS will go into syntax check mode as soon as there is an error. Your program will still run to completion but it wont do any more processing as it sets zero observations to be processed.
There is another option ERRORABEND. This will close your SAS session when an error occurs. This option is more useful for batch jobs as while execution halts, it also closes your batch session.
I'm not a fan of adding generic process checking code to programs. I would rather rely on simple SAS system options which will automatically handle any job errors in an appropriate way.
This feature has only been requested over 20 years, so it may come one day,
In the meantime, the link to a workaround in this page may help.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.