Stops executing the current DATA step, SAS job, or SAS session.
| Valid in: | DATA step |
|---|---|
| Category: | Action |
| Type: | Executable |
| Restriction: | This statement is not supported in a DATA step that runs in CAS. |
| UNIX specifics: | Values of n |
| Windows specifics: | Action of the ABEND and RETURN options; maximum value of condition-code |
| z/OS specifics: | Action of ABEND and RETURN, maximum value of n |
| See: | ABORT Statement in SAS Companion for Windows, SAS Companion for z/OS, and SAS Companion for UNIX Environments |
Table of Contents
If you specify no argument, the ABORT statement triggers the following actions under these methods of operation:
causes abnormal termination of the current SAS job or session. Actions depend on the method of operation.
causes the execution of the submitted statements to be canceled. Actions depend on the method of operation.
when coded as an option to the CANCEL argument in an autoexec file or in a %INCLUDE file, causes only the contents of the autoexec file or %INCLUDE file to be cleared by the ABORT statement. Other submitted source statements are executed after the autoexec file or %INCLUDE file.
| Restriction | The CANCEL argument cannot be submitted using SAS/SHARE, SAS/CONNECT, or SAS/AF. |
|---|---|
| Note | When the ABORT CANCEL FILE option is executed within a %INCLUDE file, all open macros are closed and execution resumes at the next source line of code. |
causes the immediate normal termination of the current SAS job or session. Results depend on the method of operation.
is an integer value that enables you to specify a condition code.
suppresses the output of all variables to the SAS log.
| Requirement | NOLIST must be the last option in the ABORT statement. |
|---|
The ABORT statement causes SAS to stop processing the current DATA step. What happens next depends on the following information:
The ABORT statement usually appears in a clause of an IF-THEN statement or in a SELECT statement that is designed to stop processing when an error occurs.
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.
The n option enables you to specify the value of the exit status code that SAS returns to the shell when it stops executing. The value of n can range from 0 to 255. Normally, a return code of 0 is used to indicate that the program ran with no errors. Return codes greater than 0 are used to indicate progressively more serious error conditions. Return codes of 0–6 and those codes that are greater than 977 are reserved for use by SAS.
The ABEND and RETURN options both terminate the SAS process, job, or session.
You can use the ABORT statement to control the conditional execution of z/OS job steps. For example, depending on the result of the z/OS job step that executes your SAS program, you might need to either bypass or execute later steps. To enable this control, establish a variable in your SAS DATA step program that is set to a particular value whenever an error occurs. In this example, a variable named Errcode is set to 16 if an error occurs in the DATA step. You can choose any variable name and value that are required by your program. Then, use the ABORT statement, coded in the THEN clause of an IF statement, to cause the z/OS job step to ABEND if ERRCODE=16.
if errcode=16 then abort return;
When the z/OS job step that is used to execute your SAS job ends (either normally or abnormally), the next z/OS job step is processed. You could then use this EXEC statement to conditionally execute that job step if an ABEND occurs. If ERRCODE is not set to 16, the ABORT statement is disabled, and because an ABEND did not occur the job step is bypassed.
//stepname EXEC
PGM=your-program,COND=ONLY
If a SAS session abends when it is processing an ABORT statement, and SAS allocated data sets during FILENAME or LIBNAME processing, then SAS uses the normal termination disposition to deallocate the data sets. For more information, see the description of the DISP option for FILENAME Statement: z/OS in SAS Companion for z/OS or LIBNAME Statement: z/OS in SAS Companion for z/OS.
This example uses the ABORT statement as part of an IF-THEN statement to stop processing when SAS encounters a data value that would otherwise cause a division-by-zero condition.
data test;
mass=100;
volume=0;
if volume=0 then abort 255;
density=mass/volume;
run;
When the ABORT statement executes, SAS returns the condition code 255 to the operating environment.