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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
TimB_SAS
SAS Employee

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

3 REPLIES 3
SASKiwi
PROC Star

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?

TimB_SAS
SAS Employee

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.

BenConner
Pyrite | Level 9

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 19381 views
  • 7 likes
  • 4 in conversation