3

is there a simple option that will cause SAS to stop running when it encounters an error. Something similar to the option ERRORABEND, except without quitting SAS?

I have seen other questions - e.g. Stop SAS Program on Error, and Stop SAS macro execution on error however those questions seemed somewhat different in that either dealing with remote server / handling expected errors at known places. I find it hard to believe/understand that there is no simple way of stopping at errors except by placing macros throughout the code to look for errors.

Community
  • 1
  • 1
kyrenia
  • 5,431
  • 9
  • 63
  • 93
  • Do you mean when running interactively? – Robert Penridge May 11 '15 at 18:14
  • @RobertPenridge I mean, when i hit submit to run the code, i want it to run until it reaches an error, and then stop (rather than attempting to move on to the next line of code despite the error). – kyrenia May 11 '15 at 18:17
  • Why do you need to do this? When SAS encounters an error it sets the `observations` option to 0 and continues processing, but of course nothing else happens when subsequent statements are processed. So is it that you just don't the log output or something? – itzy May 11 '15 at 19:28
  • @itzy main reason is to save time having to go through the log to looking to see if/where errors occurred. - so yeh, just basically don't want to log the output subsequent to an error, if that is possible. – kyrenia May 11 '15 at 19:35
  • 1
    possible duplicate of [Is there a way to make SAS stop upon the first warning or error?](http://stackoverflow.com/questions/9009944/is-there-a-way-to-make-sas-stop-upon-the-first-warning-or-error) – user667489 May 11 '15 at 21:18
  • 1
    Here's a another [similar question](http://stackoverflow.com/questions/18281108/stop-sas-execution). And here's [a paper](http://analytics.ncsu.edu/sesug/2010/CC07.Blanchette.pdf) with another solution. – DWal May 12 '15 at 00:14
  • 1
    Actually, I have never questioned this behaviour, but when I think about it, you are right. It should be possible in interactive SAS to halt the submissions of code when an error or warning occurs. As far as I know, this is not possible. I suggest you make a [SASware Ballot](http://support.sas.com/community/newsletters/news/2014/sasideas.html) submission. – Stig Eide May 12 '15 at 07:27
  • @Dwal That alternate solution is very clever - you should actually list it as an answer in both this Q and the original non-dupe. I wish I knew about it before writing thousands of `run` and `quit` statements =( – Robert Penridge May 13 '15 at 23:16
  • @DWal The more I think about it, the better the `%runquit;` macro gets. Searching for that first error in the log is a pain. This would simplify it. Especially for SAS beginners who end up trying to debug a subsequent error that occurred because of an earlier error. This should be the default SAS behaviour IMO. You also don't need to remember if the dataset ends with a `run` or a `quit`. – Robert Penridge May 13 '15 at 23:20

2 Answers2

0

I believe the thing you are looking for is the break button on the application toolbar. It is the exclamation mark with the circle around it.

Note: make sure not to hit the clear all button (which is the stylized 'X')!! It will clear all your program editor code and cannot be undone.

Sasha
  • 25
  • 5
-1

You can use options syntaxcheck ; to enable syntax-checking mode after an error.

So, to enable what I think you want to achieve :

options noerrorabend syntaxcheck ;

https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#base-sysop-syntaxcheck.htm

Chris J
  • 7,549
  • 2
  • 25
  • 25
  • Chris - that only works for non-interactive sessions (ie. batch session). – Robert Penridge May 11 '15 at 22:22
  • syntaxcheck (and obs=0) is default when SAS encounters an error, but it will not prevent the rest of the code to be submitted, only prevent it from being executed. I think OP wants to keep the log free of the clutter that this will make. – Stig Eide May 12 '15 at 07:39