Desktop productivity for business analysts and programmers

stop EG upon first error

Posts: 1

stop EG upon first error

Hi friends.

Is there an automatic way to make SAS stop upon the first error?

The other way is using  for each node  conditional processing, and  for each node check macro variables SYSERR,  but if you have an EG program with a lot of nodes ….. this mean  rewrite all !!! 

Thanks in advance

Occasional Contributor
Posts: 5

Re: stop EG upon first error

how about ENDSAS

Community Manager
Posts: 3,462

Re: stop EG upon first error

ENDSAS isn't a good idea in EG -- it terminates your SAS session and you'll lose anything in WORK, and you might not get all of your log content (with the errors).  It's like hanging up the phone before you get any answers.

Other than conditional nodes (which you mentioned), there isn't currently a good approach to "abandon" a process flow upon the first error.


Super Contributor
Posts: 310

Re: stop EG upon first error

Posted in reply to ChrisHemedinger

What version of EG are you using? Beginning with EG 4.2, you can run a branch conditionally . . .

Super User
Posts: 6,934

Re: stop EG upon first error

Well, you don't really define what it means to "make SAS stop", so here's one thought that involves a smaller amount of rewrite.  You would have to replace all your RUN; statements with a macro call:  %RUNN

Then macro could look like this:

%macro RUNN;

   %global _cancel_;

   run &_cancel_;

   %if &syserr > 0 %then %let _cancel_ = cancel;

%mend RUNN;

It's based upon the idea that this statement does not run the DATA or PROC step:

run cancel;

However, it will still fill up your log, reflecting the steps that were canceled.

If you want to debug your process, then re-run it, you would have to add this statement up front:

%let _cancel_=;

It's a little unwieldy for EG, since you have to work with the EG-generated code to locate the RUN; statements, and you might even need additional functionality for the QUIT; statements.

Good luck.

Super User
Posts: 4,024

Re: stop EG upon first error

While it wont stop on the first error the SAS option SYNTAXCHECK will force SAS into syntax check mode which means it will run the rest of the process steps only checking code and not doing any processing.

In EG this has to be set at the top of each code/process submission because EG switches it back to NOSYNTAXCHECK at the start of the next RUN.

Trusted Advisor
Posts: 3,215

Re: stop EG upon first error

When you are used to program in the DMS / Base environment ...and have a lot of nodes in one long manual sas-code.

The Eguide approach is a little bit different. You have your job-flow approach to segregate the process it in logical (smaller) steps.

Advice: Split up you old code in smaller logical parts.

This will make restarting en reviewing much more easier and you have solved the "stop at error" request, all is part of the job-flow approach.

Normally a dependant (flow) source will not run when the first source generated errors.

A lot more is possible:

To Run or Not to Run: Apply Conditions to Your Tasks

---->-- ja karman --<-----
Posts: 399

Re: stop EG upon first error


Add Options errorabend; as the first step in your project. Either in prestep (Tools-Options-SAS programs-Custom code before...) or in a program object.

It will stop any execution immideately when an error occurs, but also close the connection to the SAS server, meaning all work data is lost!


Ask a Question
Discussion stats
  • 7 replies
  • 8 in conversation