DATA Step, Macro, Functions and more

Continue after errors

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 115
Accepted Solution

Continue after errors

I have a SAS batch script running under Windows with several steps.

Sometimes the first steps fail and it stops the entire script.

I want to script to run from start to end regardless of any errors, any way of doing this?


Accepted Solutions
Solution
‎03-27-2012 09:21 AM
SAS Employee
Posts: 25

Continue after errors

ERRORABEND will end the SAS session after an error, is this what is happening?  More often after an error SAS will go into syntax-check mode and set OBS=0.

To avoid this, you can use:  OPTIONS NOSYNTAXCHECK ;  at the top of your program code.

View solution in original post


All Replies
Super User
Posts: 3,254

Continue after errors

I suggest you check to see if the SAS option ERRORABEND is set (use PROC OPTIONS). If I remember correctly I think this is the default for batch programs. Try setting OPTIONS NOERRORABEND; at the top of your program - does this change the behaviour?

Solution
‎03-27-2012 09:21 AM
SAS Employee
Posts: 25

Continue after errors

ERRORABEND will end the SAS session after an error, is this what is happening?  More often after an error SAS will go into syntax-check mode and set OBS=0.

To avoid this, you can use:  OPTIONS NOSYNTAXCHECK ;  at the top of your program code.

Regular Contributor
Posts: 179

Re: Continue after errors

Hi,

The intent here is to have a final 'Final Status' step at the end of the batch job to email the results of this job to someone who cares.  These options will allow that step to execute.  Thanks!

The &syserr value gets reset after the final data step starts, so what I did was capture the value prior to that point.  I can use this now to accurately report the status of the job.

Interestingly, the value of syserr changed from 1012 right after the first data step to a value of 3 later on.  Any ideas why? That was strange, but still acceptable.

Thanks much!

--Ben

data test;

infile '~/notfound';

input missing 6.;

put _all_;

run;

%put syserr=&syserr;

proc contents data=work._all_;

run;

%put syserr=&syserr;

%let joberror=&syserr;

options obs=1 nosyntaxcheck;

data _null_;

put "Last error found was: &joberror";

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 4107 views
  • 6 likes
  • 4 in conversation