Stop programs if error occurs

Reply
Contributor
Posts: 21

Stop programs if error occurs

Hi I was hoping if someone could help me, I have inheritted a process from one of my colleagues that has now left the business, I have to run a program on a monthly basis. this program is a mixture of Data Steps and Proc SQL code and usually takes about 8 hours to complete. Sometimes errors occur and is recorded in the log, when this happens i have to re-run the whole program again. Is there anyway that I can make SAS stop running the program when an error occurs so i can restart it from the point of failure. Your help in this matter would be much appreciated

Super User
Posts: 9,300

Re: Stop programs if error occurs

Dissect the code into smaller pieces that are run by the scheduler in succession; make them dependent, so that a job can only start when the previous job ended successfully.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 12,676

Re: Stop programs if error occurs

One of the options would be to set the system option ERRORABEND.

You could add the statement

 

Options errorabend;

at the start of the program.

From the documentation:

ERRORABEND

specifies that SAS terminate for most errors (including syntax errors and file not found errors) that would normally cause it to issue an error message, set OBS=0, and go into syntax-check mode (if syntax checking is enabled). SAS also terminates if an error occurs in any global statement other than the LIBNAME and FILENAME statements.

Tip Use the ERRORABEND system option with SAS production programs, which presumably should not encounter any errors. If errors are encountered and ERRORABEND is in effect, SAS brings the errors to your attention immediately by terminating. ERRORABEND does not affect how SAS handles notes such as invalid data messages.
 
This option may work better in a batch job where the log is preserved.
Respected Advisor
Posts: 3,818

Re: Stop programs if error occurs


@zdassu wrote:

Hi I was hoping if someone could help me, I have inheritted a process from one of my colleagues that has now left the business, I have to run a program on a monthly basis. this program is a mixture of Data Steps and Proc SQL code and usually takes about 8 hours to complete. Sometimes errors occur and is recorded in the log, when this happens i have to re-run the whole program again. Is there anyway that I can make SAS stop running the program when an error occurs so i can restart it from the point of failure. Your help in this matter would be much appreciated


8 hours Lordy! I would look to improve performance of the existing program, it is usually not very hard make modifications that greatly improve overall performance.  Often times a long running program is rather naively written, ADAM.ADLB in Pharma for example.   

 

SAS has facilities for checkpoint restarting but I have no experience using those.  It would be nice if someone from SAS or other user could provide an example, or reference to paper or blog post.

Ask a Question
Discussion stats
  • 3 replies
  • 71 views
  • 2 likes
  • 4 in conversation