BookmarkSubscribeRSS Feed
prizzo60
Calcite | Level 5

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

8 REPLIES 8
flysnow
Calcite | Level 5

how about ENDSAS

ChrisHemedinger
Community Manager

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.

Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Fugue
Quartz | Level 8

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

Astounding
PROC Star

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.

SASKiwi
PROC Star

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.

jakarman
Barite | Level 11

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:  http://support.sas.com/resources/papers/proceedings09/320-2009.pdf

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

---->-- ja karman --<-----
FredrikE
Rhodochrosite | Level 12

Hi!

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!

//Fredrik

agoldma
Pyrite | Level 9

See Casey Smith's reply in this thread:

https://communities.sas.com/t5/SAS-Enterprise-Guide/Making-EG-Stop-Executing-subsequent-process-flow...

Project Properties > Code Submission > Action to take on errors during execution

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 7830 views
  • 9 likes
  • 9 in conversation