%ABORT
Stops the macro that is
executing along with the current SAS job, or SAS session.
Syntax
|
%ABORT <ABEND
| RETURN <n>> ; |
ABEND
causes abnormal termination of the current macro and SAS job or session. Results depend on the method of operation:
·
batch mode and noninteractive mode
o
stops processing immediately
o
sends an error message to the SAS log that states
that execution was terminated by the ABEND option of the %ABORT macro statement
o
does not execute any subsequent statements or check
syntax
o
returns control to the operating environment;
further action is based on how your operating environment and your site treat
jobs that end abnormally.
·
windowing environment and interactive line mode
o
causes your macro, windowing environment, and
interactive line mode to stop processing immediately and return you to your
operating environment.
causes abnormal
termination of the current macro and SAS job or session. Results depend on the
method of operation:
·
batch mode and noninteractive mode
o
stops processing immediately
o
sends an error message to the SAS log that states
that execution was terminated by the RETURN option of the %ABORT macro
statement
o
does not execute any subsequent statements or
check syntax
o
returns control to the operating environment with
a condition code indicating an error
·
windowing environment and interactive line mode
o
causes your macro, windowing environment, and
interactive line mode to stop processing immediately and return you to your
operating environment.
n
is an integer value that
enables you to specify a condition code that SAS returns to the operating
environment when it stops executing. The range of values for n depends on your operating environment.
Without Arguments |
The
%ABORT macro statement stops the macro that is executing
along with the current SAS job, or SAS session. No other SAS statements are processed.
Here is an example:
Code
options
mprint mlogic symbolgen;
%macro
example;
%if %sysfunc(weekday(%sysfunc(today())))=1 or
%sysfunc(weekday(%sysfunc(today())))=7
%then %do;
%put Today is Saturday or Sunday, so no
reports will be run today.;
%abort
%end;
%else %do;
%put Running Reports...;
%end;
libname mylib 'c:\';
data mylib.abort;
put 'just a check to see if this data set
is executed';
x=1;
run;
%mend;
%example
Log
1 options mprint mlogic symbolgen;
2 %macro example;
3
4 %if
%sysfunc(weekday(%sysfunc(today())))=1 or %sysfunc(weekday(%sysfunc(today())))=7
4 !
%then %do;
5 %put Today is Saturday or
Sunday, so no reports will be run today.;
6 %abort
7 %end;
8 %else %do;
9 %put Running Reports...;
10 %end;
11
12 libname mylib 'c:\';
13 data mylib.abort;
14 put 'just a check to see if this
data set is executed';
15 x=1;
16 run;
17
18 %mend;
19
20 %example
MLOGIC(EXAMPLE): Beginning execution.
MLOGIC(EXAMPLE): %IF condition
%sysfunc(weekday(%sysfunc(today())))=1 or
%sysfunc(weekday(%sysfunc(today())))=7
is TRUE
MLOGIC(EXAMPLE): %PUT Today is Saturday or Sunday, so no
reports will be run today.
Today is
Saturday or Sunday, so no reports will be run today.
MLOGIC(EXAMPLE): %ABORT
ERROR:
Execution terminated by an %ABORT statement.
ERROR:
Execution terminated by an %ABORT statement.
ERROR:
Execution terminated by an %ABORT statement.
ERROR: Errors
printed on page 1.
ERROR: Errors
printed on page 1.
ERROR: Errors
printed on page 1.
NOTE: SAS
Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS
System used:
real time 16.15 seconds
cpu time 2.52 seconds