Dictionary
%ABORT Statement
Stops the macro that is executing along with the current DATA step, SAS job, or SAS session.
Type: Macro statement
Restriction: Allowed in macro definitions only
Syntax
%ABORT <ABEND | CANCEL | <FILE> | RETURN | <n>>;
Required Arguments
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.
stops processing immediately.
sends an error message to the SAS log that states that execution was
terminated by the ABEND option of the %ABORT macro statement
does not execute any subsequent statements or check syntax
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.
causes your macro, windowing environment, and interactive line mode to
stop processing immediately and return you to your operating environment.
CANCEL <FILE>
causes the cancellation of the current submitted statements. The results depend on
the method of operation.
If the method of operation is batch mode and noninteractive mode, use the CANCEL
option to do the following:
The entire SAS program and SAS system are terminated.
The error message is written to the SAS log.
If the method of operation is windowing environment and interactive line mode, use
the CANCEL option to do the following:
It only clears the current submitted program.
Other subsequent submitted programs are not affected.
The error message is written to the SAS log.
302 Chapter 19 Macro Statements
If the method of operation is workspace server and stored process server, use the
CANCEL option to do the following:
It only clears currently submitted program.
Other subsequent submit calls are not affected.
The error message is written to the SAS log.
If the method of operation is SAS IntrNet application server, use the CANCEL
option to do the following:
A separate execution is created for each request. The execution submits the
request code. A CANCEL in the request code clears the current submitted code
but does not terminate the execution or the SAS session.
FILE
when coded as an option to the CANCEL argument in an autoexec file or in a
%INCLUDE file, causes only the contents of the autoexec file or %INCLUDE
file to be cleared by the %ABORT statement. Other submitted source statements
will be executed after the autoexec or %INCLUDE file.
Restriction
The CANCEL argument cannot be submitted using SAS/SHARE,
SAS/CONNECT, or SAS/AF.
CAUTION
When %ABORT CANCEL FILE option is executed within a
%INCLUDE file, all open macros are closed and execution
resumes at the next source line of code.
RETURN
causes abnormal termination of the current macro and SAS job or session. Results
depend on the method of operation:
batch mode and noninteractive mode
stops processing immediately
sends an error message to the SAS log that states that execution was
terminated by the RETURN option of the %ABORT macro statement
does not execute any subsequent statements or check syntax
returns control to the operating environment with a condition code indicating
an error
windowing environment and interactive line mode
causes your macro, windowing environment, and interactive line mode to
stop processing immediately and return you to your operating environment
n
an integer value that enables you to specify a condition code:
When used with the CANCEL argument, the value is placed in the SYSINFO
automatic macro variable.
When it is NOT used with the CANCEL statement, SAS returns the value to the
operating environment when the execution stops. The range of values for n
depends on your operating environment.
%ABORT Statement 303
Details
If you specify no argument, the %ABORT macro statement produces these results under
the following methods of operation:
batch mode and noninteractive mode.
stops processing the current macro and DATA step and writes an error message
to the SAS log. Data sets can contain an incomplete number of observations or
no observations, depending on when SAS encountered the %ABORT macro
statement.
sets the OBS= system option to 0.
continues limited processing of the remainder of the SAS job, including
executing macro statements, executing system option statements, and syntax
checking of program statements.
windowing environment
stops processing the current macro and DATA step
creates a data set that contains the observations that are processed before the
%ABORT macro statement is encountered
prints a message to the log that an %ABORT macro statement terminated the
DATA step
interactive line mode
stops processing the current macro and DATA step. Any further DATA steps or
procedures execute normally.
Comparisons
The %ABORT macro statement causes SAS to stop processing the current macro and
DATA step. What happens next depends on
the method that you use to submit your SAS statements
the arguments that you use with %ABORT
your operating environment
The %ABORT macro statement usually appears in a clause of an %IF-%THEN macro
statement that is designed to stop processing when an error condition occurs.
Note: The return code generated by the %ABORT macro statement is ignored by SAS if
the system option ERRORABEND is in effect.
Note: When you execute an %ABORT macro statement in a DATA step, SAS does not
use data sets that were created in the step to replace existing data sets with the same
name.
%* Macro Comment Statement
Designates comment text.
Type: Macro statement
Restriction: Allowed in macro definitions or open code
304 Chapter 19 Macro Statements
Syntax
%*commentary;
Required Argument
commentary
is a descriptive message of any length.
Details
The macro comment statement is useful for describing macro code. Text from a macro
comment statement is not constant text and is not stored in a compiled macro. Because a
semicolon ends the comment statement, the comment cannot contain internal semicolons
unless the internal semicolons are enclosed in quotation marks. Macro comment
statements are not recognized when they are enclosed in quotation marks.
Macro comment statements are complete macro statements and are processed by the
macro facility. Quotation marks within a macro comment must match.
Only macro comment statements and SAS comments of the form /*commentary*/ in
macro definitions or open code might be used to hide macro statements from processing
by the macro facility.
Comparisons
SAS comment statements of the form
*commentary;
or
comment commentary;
are complete SAS statements. Consequently, they are processed by the tokenizer and
macro facility and cannot contain semicolons or unmatched quotation marks. SAS
comment statements of the form
*commentary;
or
comment commentary;
are stored as constant text in a compiled macro. These two types will execute any macro
statements within a comment. SAS recommends not to use these within a macro
definition.
SAS comments in the form
/*commentary*/
are not tokenized, but are processed as a string of characters. These comments can
appear anywhere a single blank can appear and can contain semicolons or unmatched
quotation marks. SAS comments in the form
/*commentary*/
are not stored in a compiled macro.
%* Macro Comment Statement 305
Example: Contrasting Comment Types
This code defines and invokes the macro VERDATA, which checks for data errors. It
contains a macro comment statement and SAS comments in the form /
*
commentary*/ and *commentary;
%macro verdata(in, thresh);
*%let thresh = 5;
/* The preceding SAS comment does not hide the %let statement
as does this type of SAS comment.
%let thresh = 6;
*/
%if %length(&in) > 0 %then %do;
%* infile given;
data check;
/* Jim's data */
infile &in;
input x y z;
* check data;
if x<&thresh or y<&thresh or z<&thresh then list;
run;
%end;
%else %put Error: No infile specified;
%mend verdata;
%verdata(ina, 0)
When you execute VERDATA, the macro processor generates the following:
DATA CHECK;
INFILE INA;
INPUT X Y Z;
* CHECK DATA;
IF X<5 OR Y<5 OR Z<5 THEN LIST;
RUN;
%COPY Statement
Copies specified items from a SAS macro library.
Type: Macro statement
Restriction: Allowed in macro definitions or open code
See: “%MACRO Statement” on page 325 and “SASMSTORE= System Option” on page
384
Syntax
%COPY macro-name / <option-1 <option-2> …> SOURCE
Required Arguments
macro-name
name of the macro that the %COPY statement will use.
306 Chapter 19 Macro Statements
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset