Stops executing the current DATA step, SAS job, or SAS session
Valid: in a DATA step
Category: Action
Type: Executable
See: ABORT Statement in the documentation for your operating environment.
ABORT <ABEND RETURN> < n >;
If you specify no argument, the ABORT statement produces these results under the following methods of operation:
batch mode and noninteractive mode
stops processing the current DATA step and writes an error message to the SAS log. Data sets can contain an incomplete number of observations or no observations, depending on when SAS encountered the ABORT statement.
sets the OBS= system option to 0.
continues limited processing of the remainder of the SAS job, including executing macro statements, executing system options statements, and syntax checking of program statements.
creates output data sets for subsequent DATA and PROC steps with no observations.
windowing environment
stops processing the current DATA step
creates a data set that contains the observations that are processed before the ABORT statement is encountered
prints a message to the log that an ABORT statement terminated the DATA step
continues processing any DATA or PROC steps that follow the ABORT statement.
interactive line mode
stops processing the current DATA step. Any further DATA steps or procedures execute normally.
ABEND
causes abnormal termination of the current SAS job or session. Results depend on the method of operation:
batch mode and noninteractive mode
stops processing immediately
sends an error message to the SAS log that states that execution was terminated by the ABEND option of the ABORT statement
does not execute any subsequent statements or check syntax
returns control to the operating environment; further action is based on how your operating environment and your site treat jobs that end abnormally.
windowing environment and interactive line mode
causes your windowing environment and interactive line mode to stop processing immediately and return you to your operating environment.
RETURN
causes the immediate normal termination of the current SAS job or session. Results depend on the method of operation:
batch mode and noninteractive mode
stops processing immediately
sends an error message to the SAS log stating that execution was terminated by the RETURN option of the ABORT statement
does not execute any subsequent statements or check syntax
returns control to your operating environment with a condition code indicating an error
windowing environment and interactive line mode
causes your windowing environment and interactive line mode to stop processing immediately and return you to your operating environment.
n
is an integer value that enables you to specify a condition code that SAS returns to the operating environment when it stops executing.
Operating Environment Information: The range of values for n depends on your operating environment.
The ABORT statement causes SAS to stop processing the current DATA step. What happens next depends on
the method you use to submit your SAS statements
the arguments you use with ABORT
your operating environment.
The ABORT statement usually appears in a clause of an IF-THEN statement or a SELECT statement that is designed to stop processing when an error condition occurs.
Note: The return code generated by the ABORT statement is ignored by SAS if the system option ERRORABEND is in effect.
Note: When you execute an ABORT statement in a DATA step, SAS does not use data sets that were created in the step to replace existing data sets with the same name .
Operating Environment Information: The only difference between the ABEND and RETURN options is that with ABEND further action is based on how your operating environment and site treat jobs that end abnormally. RETURN simply returns a condition code that indicates an error.
When you use the SAS windowing environment or interactive line mode, the ABORT statement and the STOP statement both stop processing. The ABORT statement sets the value of the automatic variable _ERROR_ to 1, and the STOP statement does not.
In batch or noninteractive mode, the ABORT and STOP statements also have different effects. Both stop processing, but only ABORT sets the value of the automatic variable _ERROR_ to 1. Use the STOP statement, therefore, when you want to stop only the current DATA step and continue processing with the next step.
This example uses the ABORT statement as part of an IF-THEN statement to stop execution of SAS when it encounters a data value that would otherwise cause a division-by-zero condition.
if volume=0 then abort 255; density=mass/volume;
The n value causes SAS to return the condition code 255 to the operating environment when the ABORT statement executes.
Statement:
'STOP Statement' on page 1405