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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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