BookmarkSubscribeRSS Feed

There is still no way to stop a program from executing further statements except by killing the session by aborting it.

 

Many years ago I kludged together a workaround, but I reckon a proper way to stop a program without generating an error or aborting the session is needed.

7 Comments
FriedEgg
SAS Employee

Aren't you talking about what abort already does with the cancel argument?

 

data ...; abort cancel; run;

*or;

%abort cancel;
ChrisNZ
Tourmaline | Level 20

This still generates an error sadly.

FriedEgg
SAS Employee

Seems to me like a self-created problem.  If you don't want the error message then write the program as a macro and either control your process flow with %if statements and labels or using %return when you want to stop processing...

 

 

 

ChrisNZ
Tourmaline | Level 20

Self-created? How?

Having to embed all the code in a macro is exactly why I wrote my "kludge". Sometimes, it is just too much of a pain.

 

Having a way to stop a program from running any further without creating an error (a big no-no in production systems) does seem a very sensible, if not obvious, feature to me.

 

FriedEgg
SAS Employee

Don't get me wrong, I think making something like the stop statement global could be useful.  I just see many already existing alternatives which are due their merit here and are far less of a kludge (I found yours to be quite clever)

ChrisNZ
Tourmaline | Level 20

> clever

Thank you!  🙂

 

>many already existing alternatives

There is only one way I can think of: put all the code in a huge macro that serves no other purpose than to stop the steps it contains.

RobP
Quartz | Level 8

I can't believe this doesn't have more upvotes.  Error handling in SAS in general falls somewhere between non-existent and terrible.... If you want to achieve anything that has a minor semblance of performing checks and error handling then it usually involved a LOT of rolling your own non-standardized, non-portable code.