DATA Step, Macro, Functions and more

Stop SAS when error

Reply
Contributor
Posts: 42

Stop SAS when error

Hi,

I have 1500 lines off SAS code which can take up to 2 hours to run, how do I add a stop execution upon finding an error?

Thanks in advance
Valued Guide
Posts: 561

Re: Stop SAS when error

Posted in reply to Brandon16

To be honest 1,500 lines of code isn't really the problem (I've seen much bigger programs) it's the quantity of data and how it's being processed which is causing the long run time.

 

You could set the errorcheck option to STRICT as documented here -> http://documentation.sas.com/?docsetId=lesysoptsref&docsetTarget=n074sx2hkq8dzpn1ptoydcmzfspt.htm&do...

 

or use the errorabend option but that will terminate the whole session leaving you no wiser as to what went wrong....

Super User
Super User
Posts: 9,227

Re: Stop SAS when error

Posted in reply to Brandon16

Ensure the 1500 lines of code has been: modularised, validated, and stress tested.  Then an unexpected error will not happen.  Modularising the code will allow you to block the whole process up into smaller chunks, allowing for conditionally checking at various points.  

The question really is what does your documentation on the process say - you do have all the documentation e.g. functional design, testing, data structures etc.

Contributor
Posts: 42

Re: Stop SAS when error

Posted in reply to Brandon16
Each month code is added by a range a different users and therefore that's why i want to include this ch eck.

Still unsure how I do this.
Super User
Super User
Posts: 9,227

Re: Stop SAS when error

Posted in reply to Brandon16

Even more reason for modularistion and documentation.  Each new block should be documented and validated before being moved into the production process.

Super User
Posts: 10,626

Re: Stop SAS when error

Posted in reply to Brandon16

Try these two options.

 

options errorabend nosyntaxcheck;

PROC Star
Posts: 1,435

Re: Stop SAS when error

@Ksharp, what is the benefit of adding nosyntaxcheck? I think errorabend would be enough. As I understand it, nosyntaxcheck is used to tell SAS to keep executing code after an error, rather than entering syntax check mode.
Contributor
Posts: 42

Re: Stop SAS when error

Posted in reply to Brandon16
Do I add this at the start of my code and execute the whole program?
Super User
Posts: 10,626

Re: Stop SAS when error

Posted in reply to Brandon16
Yes. Or add into autoexec.sas
Ask a Question
Discussion stats
  • 8 replies
  • 126 views
  • 0 likes
  • 5 in conversation