Chapter Contents |
Previous |
Next |
ABORT |
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.
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.