I need to get SAS to trigger an error if a certain condition is not meet i have tried to use abort return n, abort abend etc.. but they all seems to to disconnect the entire session where i only want to get an error like with syntax etc.
It is a sas propgram only to be run from SAS-EG in interactive mode with prompts
my code:
DATA _NULL_;
IF prxmatch("/^TBDLZL\d{4}_[A-Z]/",&tablename_in) eq 0 then do;
put "error table name &tablename_in does not match";
ABORT RETURN 15;
END;
RUN;
any suggestions ?
Use the ABORT CANCEL
statement. The data step will stop running and the following steps in the submitted code will not be processed.
For example:
data _null_;
set sashelp.class;
if name = "John" then do;
put 'ERR' 'OR: My error message';
abort cancel;
end;
run;
* This step is not done due to earlier ABORT CANCEL;
data _null_;
set sashelp.class;
where name like 'J%';
run;
From Help:
CANCEL
causes the execution of the submitted statements to be canceled. Actions depend on the method of operation.
batch mode and noninteractive mode
- terminates the entire SAS program and SAS system.
- writes an error message to the SAS log.
windowing environment and interactive line mode
- clears only the current submitted program.
- does not affect other subsequent submitted programs.
- writes an error to the SAS log.
workspace server and stored process server
- clears only the currently submitted program.
- does not affect other subsequent submit calls.
- writes an error message to the SAS log.
SAS IntrNet application server
- creates a separate execution for each request and submits the request code. A CANCEL argument in the request code clears the current submitted code but does not terminate the execution or the SAS session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With