Sets _ERROR_ to 1. A message written to the SAS log is optional.
| Valid in: | DATA step |
|---|---|
| Categories: | Action |
| CAS | |
| Type: | Executable |
Using ERROR without an argument sets the automatic variable _ERROR_ to 1 and writes a blank message to the SAS log.
writes a message to the SAS log.
| Tip | Message can include character literals (enclosed in quotation marks), variable names, formats, and pointer controls. |
|---|
The ERROR statement sets the automatic variable _ERROR_ to 1. Writing a message that you specify to the SAS log is optional. When _ERROR_ = 1, SAS writes the data lines that correspond to the current observation in the SAS log.
Using ERROR is equivalent to using these statements in combination:
SAS writes the error message and the variable name and value to the SAS log for each observation that satisfies the condition in the IF-THEN statement.
file file-specification;
if type='teen' & age > 19 then
error 'type and age don"t match ' age=;
file file-specification;
if type='teen' & age > 19 then
do;
file log;
put 'type and age don"t match ' age=;
_error_=1;
file file-specification;
end;