BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
daisy6
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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.

View solution in original post

3 REPLIES 3
SuryaKiran
Meteorite | Level 14

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>
Thanks,
Suryakiran
SASKiwi
PROC Star

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.

ChrisNZ
Tourmaline | Level 20

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2727 views
  • 3 likes
  • 4 in conversation