11-14-2017 05:11 PM
What type of errors are you concerned with? In data step code or procedures? And what would you like to happen when the program stops?
Also is this interactive or in batch mode?
And is the code in an %include file?
In a data step you may want to use Abort Cancel;
11-15-2017 09:22 AM
>What type of errors are you concerned with?
>In data step code or procedures?
>And what would you like to happen when the program stops?
Stop executing any process and rollback to the previous state.
>Also is this interactive or in batch mode?
>And is the code in an %include file?
Not the code I'm working on now.
Basically in my code one procedure depends on output from another procedure and it seems like wasting time to continue processing if any point in that chain fails.
11-15-2017 11:57 AM
I'm not sure what you mean by "rollback to previous state" but most of the serious errors SAS does not replace data sets.
Your requirement for any error in data step or procedure and in both batch or interactive mode is likely not going to be accomplished with a simple line or two of code.
For example starting with the some basic Error system options such as ERRORABEND, which will terminate the SAS session, may be appropriate but it will terminate the session and diagnostics from an interactive session may not be available unless you are directing the log to a file. But this only affects errors that would cause an error message and go into syntax check mode. It will not stop for errors such as invalid data read during a data step for example.
You also have ERRORBYABEND that will treat BY group errors by ending the SAS program.
These two system options are more appropriate for production jobs that are expected to be error free.
You may also need to change setting to the DKRICOND and DKROCOND system options for the behavior of drop, keep and rename statements.
DMSSYNCHK may be appropriate for the SAS windowing environment to tell SAS to enter Syntax checking mode when an error is encountered.
FMTERR option might need to be set to generate an error to halt processing for unfound format references.
VNFERR specifies whether SAS issues and error or warning when BY variables don't exist in multiple datasets used in Set, Merge, Update or Modify statements.
The Abort statement in a data step might be needed to halt some types of invalid data errors that don't always terminate a data step but would have to be added to each data step with appropriate conditions such as If _error_ then Abort. But the behavior is somewhat different for windowing and batch mode depending on options on the statement.
11-15-2017 02:04 PM
I would explore the ERRORABEND SAS option as already mentioned by @ballardw. This will work well if you are running your jobs in batch mode as your LOG files will record the processing up to the point of the ABEND.