Chapter Contents

Previous

Next
ABORT

ABORT



Stops execution of the current DATA step, SAS job, or SAS session

Valid: in a DATA step
CMS specifics: operating environment behavior


Syntax
Details

Syntax

ABORT <ABEND | RETURN> <n>;


Details

The ABORT statement causes SAS to stop processing the current DATA step. In all methods of operation, SAS stops processing the current DATA step and prints an error message in the SAS log. However, the way SAS handles the remaining DATA and PROC steps and the observations from the aborted DATA step depends on the mode of operation. Also, in windowing environments or interactive modes of operation the ABORT and STOP statements are analogous; however, in noninteractive mode, the two statements have different effects. See SAS Language Reference: Dictionary for information about using the ABORT statement in the various methods of running SAS.

The following options are used primarily in noninteractive processing; however, they can be used in any mode. These options have host-specific characteristics that enable you to terminate the operating environment job step that you are using to execute your SAS program and send return codes that can conditionally execute subsequent job steps.

ABEND
terminates the current SAS job; the return code is 5 or n if n is present.

RETURN
immediately terminates the SAS job or session; the return code indicates an error. This return code can then be used by CMS to conditionally execute later steps in an EXEC. The ABORT RETURN statement results in the return code 4 unless n is specified.

n
allows you to specify a condition code that SAS returns to its calling program or to CMS when SAS stops executing. The value of n must be an integer. Normally a return code of 0 is used to indicate that the program ran with no errors, and return codes greater than 0 are used to indicate progressively more serious error conditions. Return codes 0-6 and those greater than 997 are used by SAS.

You can use the return code from SAS to control execution from within an EXEC.

Before you perform extensive analysis on your data, you can use the ABORT statement to halt execution if the data contain errors. In the following statements, for example, the automatic variable _ERROR_ is set to 1 if errors occur in the data lines. If any errors are found, SAS stops processing observations. When SAS reads the second data line, it sets _ERROR_ to 1 and executes the ABORT statement. Data set CHECK is created with one observation. If data set CHECK already exists, it is not replaced if an error is found.

data check;
   input ssn 1-9 paycode 11-13;
   if _ERROR_ then abort;
   cards;
111222333 100
aaabbbccc 200
444555666 300
;
run;
The return code for the data step above is 3.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.