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?
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.
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?
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.
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;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.