ABORT statement

From sasCommunity
Jump to: navigation, search

The ABORT statement is used to terminate processing the current DATA Step and, optionally, cause SAS to generate an error. What happens after the DATA step is terminated will depend on the statement arguments that are used.

Syntax

ABORT < ABEND | CANCEL <FILE> | RETURN > < n > < NOLIST >;

No arguments

ABORT ;

Causes the DATA step to terminate and SAS to enter syntax check mode and continue processing the rest of the file.

ABEND argument

ABORT ABEND ;

Causes the DATA step to terminate immediately, and not process the file any further, with an error condition when returning control to the operating system with an abnormal termination code.

CANCEL argument

ABORT CANCEL ;

Causes the entire SAS program to terminate. May also terminate the SAS system in batch or non-interactive modes.

FILE optional argument

ABORT CANCEL FILE ;

Only valid in autoexecute or %INCLUDEd files. Causes execution of the file to be canceled.

RETURN argument

ABORT RETURN ;

Causes the DATA step to terminate immediately, and not process the file any further, without causing an error condition when control is returned to the operating system.

Error number (n) argument

ABORT ... n ;

The value of n is an integer which is returned as a condition code (or error code) for the step.

NOLIST argument

ABORT ... NOLIST ;

Suppresses listing variables in the SAS log. The NOLIST keyword must be the last argument in the statement.

Usage

The ABORT statement is best used in situations where an error situation is encountered that would result in SAS producing undesirable results if processing were allowed to continue. For example, it may be better to abort processing than process missing values because SAS encounters invalid data in a calculation, such as it is going to divide by zero.

The ABORT statement ends a DATA step and causes and error. If all that is desired is to stop processing the DATA step then it may be better to use the STOP statement instead.

Further reading