System Options for Macros
There are several SAS system options that apply to the macro facility.
Controls command-style macro invocation.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOCMDMAC |
CMDMAC | NOCMDMAC
CMDMAC
specifies that the macro processor examine the first word of every windowing environment command to see whether it is a command-style macro invocation.
Note: When CMDMAC is in effect, SAS searches the macro libraries first and executes any member it finds with the same name as the first word in the windowing environment command that was issued. Unexpected results can occur.
NOCMDMAC
specifies that no check be made for command-style macro invocations. If the macro processor encounters a command-style macro call when NOCMDMAC is in effect, it treats the call as a SAS command and produces an error message if the command is not valid or is not used correctly.
The CMDMAC system option controls whether macros defined as command-style macros can be invoked with command-style macro calls or if these macros must be invoked with name-style macro calls. These two examples illustrate command-style and name-style macro calls, respectively:
• macro-name parameter-value-1 parameter-value-2
• %macro-name(parameter-value-1, parameter-value-2)
When you use CMDMAC, processing time is increased because the macro facility searches the macros compiled during the current session for a name corresponding to the first word on the command line. If the MSTORED option is in effect, the libraries containing compiled stored macros are searched for a name corresponding to that word. If the MAUTOSOURCE option is in effect, the autocall libraries are searched for a name corresponding to that word. If the MRECALL system option is also in effect, processing time can be increased further because the search continues even if a word was not found in a previous search.
Regardless of which option is in effect, you can use a name-style invocation to call any macro, including command-style macros.
Name-style macros are the more efficient choice for invoking macros because the macro processor searches only for a macro name corresponding to a word following a percent sign.
Controls statement-style macro invocation.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOIMPLMAC |
IMPLMAC | NOIMPLMAC
IMPLMAC
specifies that the macro processor examine the first word of every submitted statement to see whether it is a statement-style macro invocation.
Note: When IMPLMAC is in effect, SAS searches the macro libraries first and executes any macro it finds with the same name as the first word in the SAS statement that was submitted. Unexpected results can occur.
NOIMPLMAC
specifies that no check be made for statement-style macro invocations. This is the default. If the macro processor encounters a statement-style macro call when NOIMPLMAC is in effect, it treats the call as a SAS statement. SAS produces an error message if the statement is not valid or if it is not used correctly.
The IMPLMAC system option controls whether macros defined as statement-style macros can be invoked with statement-style macro calls or if these macros must be invoked with name-style macro calls. These examples illustrate statement-style and name-style macro calls, respectively:
• macro-name parameter-value-1 parameter-value-2;
• %macro-name(parameter-value-1, parameter-value-2)
When you use IMPLMAC, processing time is increased because SAS searches the macros compiled during the current session for a name corresponding to the first word of each SAS statement. If the MSTORED option is in effect, the libraries containing compiled stored macros are searched for a name corresponding to that word. If the MAUTOSOURCE option is in effect, the autocall libraries are searched for a name corresponding to that word. If the MRECALL system option is also in effect, processing time can be increased further because the search continues even if a word was not found in a previous search.
Regardless of which option is in effect, you can call any macro with a name-style invocation, including statement-style macros.
Note: If a member in an autocall library or stored compiled macro catalog has the same name as an existing windowing environment command, SAS searches for the macro first if CMDMAC is in effect. Unexpected results can occur.
Name-style macros are a more efficient choice to use when you invoke macros because the macro processor searches only for the macro name that corresponds to a word that follows a percent sign.
Controls whether the SAS macro language is available.
Valid in: |
Configuration file, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
MACRO |
MACRO | NOMACRO
enables SAS to recognize and process macro language statements, macro calls, and macro variable references.
NOMACRO
prevents SAS from recognizing and processing macro language statements, macro calls, and macro variable references. The item generally is not recognized, and an error message is issued. If the macro facility is not used in a job, a small performance gain can be made by setting NOMACRO because there is no overhead of checking for macros or macro variables.
Displays in the SAS log the source location of an autocall macro when the autocall macro is compiled.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMAUTOCOMPLOC |
MAUTOCOMPLOC | NOMAUTOCOMPLOC
MAUTOCOMPLOC
displays the autocall macro source location in the SAS log when the autocall macro is compiled.
NOMAUTOCOMPLOC
prevents the autocall macro source location from being written to the SAS log.
The display created by the MAUTOCOMPLOC system option of the autocall macro source location in the log is not affected by either the MAUTOLOCDISPLAY or the MLOGIC system options.
Specifies whether to display the source location of the autocall macros in the log when the autocall macro is invoked.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMAUTOLOCDISPLAY |
MAUTOLOCDISPLAY | NOMAUTOLOCDISPLAY
MAUTOLOCDISPLAY
enables MACRO to display the autocall macro source location in the log when the autocall macro is invoked.
NOMAUTOLOCDISPLAY
prevents the autocall macro source location from being displayed in the log when the autocall macro is invoked. NOMAUTOLOCDISPLAY is the default.
When both MAUTOLOCDISPLAY and MLOGIC options are set, only the MLOGIC listing of the autocall source location is displayed.
Specifies whether the macro processor prepends the full pathname of the autocall source file to the description field of the catalog entry of compiled autocall macro definition in the Work.SASMacr catalog.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMAUTOLOCINDES |
See: |
SAS log |
MAUTOLOCINDES | NOMAUTOLOCINDES
MAUTOLOCINDES
causes the macro processor to prepend the full pathname of the autocall macro source file to the description field of the catalog entry of the compiled autocall macro definition in the Work.SASMacr catalog.
NOMAUTOLOCINDES
no changes to the description field autocall macro definitions in the Work.SASMacr catalog.
Use MAUTOLOCINDES to help determine where autocall macro definition source code is located. The following is an example that shows the output that contains the full pathname:
options mautolocindes;
%put %lowcase(THIS);
this
proc catalog cat=work.sasmacr;contents;run;
Contents of Catalog Work.SASMacr
# Name Type Create Date Modified Date Description
1 LOWCASE MACRO 12Sep10:10:36:57 12Sep10:10:36:57 C:SASv9sasdev
mva-v930shellauto
Specifies whether the autocall feature is available.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
MAUTOSOURCE |
MAUTOSOURCE | NOMAUTOSOURCE
MAUTOSOURCE
causes the macro processor to search the autocall libraries for a member with the requested name when a macro name is not found in the Work library.
NOMAUTOSOURCE
prevents the macro processor from searching the autocall libraries when a macro name is not found in the Work library.
When the macro facility searches for macros, it searches first for macros compiled in the current SAS session. If the MSTORED option is in effect, the macro facility next searches the libraries containing compiled stored macros. If the MAUTOSOURCE option is in effect, the macro facility next searches the autocall libraries.
Issues a NOTE to the SAS log. The note contains the size and number of instructions upon the completion of the compilation of a macro.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NONE |
MCOMPILENOTE=NONE | NOAUTOCALL | ALL
NONE
prevents any NOTE from being written to the log.
NOAUTOCALL
prevents any NOTE from being written to the log for AUTOCALL macros, but does issue a NOTE to the log upon the completion of the compilation of any other macro.
ALL
issues a NOTE to the log. The note contains the size and number of instructions upon the completion of the compilation of any macro.
The NOTE confirms that the compilation of the macro was completed. When the option is on and the NOTE is issued, the compiled version of the macro is available for execution. A macro can successfully compile, but still contain errors or warnings that will cause the macro to not execute as you intended.
A macro can actually compile and still contain errors. Here is an example of the NOTE without errors:
option mcompilenote=noautocall;
%macro mymacro;
%mend mymacro;
Output to the log:
NOTE: The macro MYMACRO completed compilation without errors.
Here is an example of the NOTE with errors:
%macro yourmacro;
%end;
%mend yourmacro;
Output to the log:
ERROR: There is no matching %DO statement for the %END statement.
This statement will be ignored.
NOTE: The macro YOURMACRO completed compilation with errors.
Specifies whether to allow new definitions of macros.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
MCOMPILE |
MCOMPILE | NOMCOMPILE
MCOMPILE
allows new macro definitions.
NOMCOMPILE
disallows new macro definitions.
The MCOMPILE system option allows new definitions of macros.
The NOMCOMPILE system option prevents new definitions of macros. It does not prevent the use of existing stored compiled or autocall macros.
Enables the generation of coverage analysis data.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMCOVERAGE |
Requirement: |
Must use MCOVERAGELOC= system option |
MCOVERAGE | NOMCOVERAGE
MCOVERAGE
enables the generation of coverage analysis data.
NOMCOVERAGE
prevents the generation of coverage analysis data.
MCOVERAGE system option controls the generation of coverage analysis data, which is information needed to ensure proper testing of SAS Solutions products before their release.
The format of the coverage analysis data is a space delimited flat text file that contains three types of records. Each record begins with a numeric record type. The line numbers in the data are relative line numbers based on the %MACRO keyword used to define the macro. You must use the MCOVERAGELOC= system option to specify the location of the coverage analysis data file. See “MCOVERAGELOC= System Option” on page 350.
Note: Because nested macro definitions are stored as model text with line breaks collapsed, it is recommended that nested macro definitions not be used in macro definitions that will later be analyzed for execution coverage.
Below are explanations for each of the three record types.
Record type 1:
1 n n macroname
1
record type
n
first line number
n
last line number
macroname
macro name
Record type 1 indicates the beginning of the execution of a macro. Record type 1 appears once for each invocation of a macro.
Record type 2:
2 n n macroname
2
record type
n
first line number
n
last line number
macroname
macro name
Record type 2 indicates the lines of a macro that have executed. A single line of a macro might cause more than one record to be generated.
Record type 3:
3 n n macroname
3
record type
n
first line number
n
last line number
macro name
Record type 3 indicates which lines of the macro cannot be executed because no code was generated from them. These lines might be either commentary lines or lines that cause no macro code to be generated.
The following is a sample program log:
Sample Program Log:
NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1B0)
Licensed to SAS Institute Inc., Site 1.
NOTE: This session is executing on the W32_7PRO platform.
NOTE: SAS initialization used:
real time 0.45 seconds
cpu time 0.20 seconds
1 options source source2;
2
3 options mcoverage mcoverageloc='./foo.dat';
4
5 /* 1 */ %macro
6 /* 2 */ foo (
7 /* 3 */ arg,
8 /* 4 */
9 /* 5 */
10 /* 6 */ arg2
11 /* 7 */
12 /* 8 */
13 /* 9 */ =
14 /* 10 */
15 /* 11 */ This is the default value of arg2)
16 /* 12 */ ;
17 /* 13 */ /* This is a number of lines of comments */
18 /* 14 */ /* which presumably will help the maintainer */
19 /* 15 */ /* of this macro to know what to do to keep */
20 /* 16 */ /* this silly piece of code current */
21 /* 17 */ %if &arg %then %do;
22 /* 18 */ data _null_;
23 /* 19 */ x=1;
24 /* 20 */ %end;
25 /* 21 */ %* this is a macro comment statement
26 /* 22 */ that also can be used to document features
27 /* 23 */ and other stuff about the macro;
28 /* 24 */ %else
29 /* 25 */ %do;
30 /* 26 */ DATA _NULL_;
31 /* 27 */ y=1;
32 /* 28 */ %end;
33 /* 29 */ run;
34 /* 30 */
35 /* 31 */
36 /* 32 */
37 /* 33 */
38 /* 34 */
39 /* 35 */ %mend
40 /* 36 */
41 /* 37 */
42 /* 38 */
43 /* 39 */
44 /* 40 */
45 /* 41 */
46 /* 42 */
47 /* 43 */ foo This is text which should generate a warning! ;
WARNING: Extraneous information on %MEND statement ignored for macro
definition FOO.
Specifies the location of the coverage analysis data file.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Requirement: |
Use with MCOVERAGE system option |
See: |
MCOVERAGELOC=fileref | file-specification
fileref | file-specification
a SAS fileref or an external file specification enclosed in quotation marks.
This MCOVERAGELOC = system option specifies where the coverage analysis is to be written. The option takes either an external file specification enclosed in quotation marks or a SAS fileref.
Specifies whether the macro processor issues a warning message when a macro reference cannot be resolved.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
MERROR |
MERROR | NOMERROR
MERROR
issues the following warning message when the macro processor cannot match a macro reference to a compiled macro:
WARNING: Apparent invocation of macro %text not resolved.
NOMERROR
issues no warning messages when the macro processor cannot match a macro reference to a compiled macro.
Several conditions can prevent a macro reference from resolving. These conditions appear when
• a macro name is misspelled
• a macro is called before being defined
• strings containing percent signs are encountered. For example:
TITLE Cost Expressed as %Sales;
If your program contains a percent sign in a string that could be mistaken for a macro keyword, specify NOMERROR.
Specifies whether to display macro execution information in the SAS log at macro invocation.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMEXECNOTE |
See: |
MEXECSIZE on page 352 |
MEXECNOTE | NOMEXECNOTE
MEXECNOTE
displays the macro execution information in the log when the macro is invoked.
NOMEXECNOTE
does not display the macro execution information in the log when the macro is invoked.
The MEXECNOTE option controls the generation of a NOTE in the SAS log that indicates the macro execution mode.
Specifies the maximum macro size that can be executed in memory.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
65536 |
See: |
MEXECSIZE=n | nK | nM | nG | nT | hexX | MIN | MAX
n
specifies the maximum size macro to be executed in memory available in bytes.
nK
specifies the maximum size macro to be executed in memory available in kilobytes.
nM
specifies the maximum size macro to be executed in memory available in megabytes.
nG
specifies the maximum size macro to be executed in memory available in gigabytes.
nT
specifies the maximum size macro to be executed in memory available in terabytes.
MIN
specifies the minimum size macro to be executed in memory. Minimum value is 0.
MAX
specifies the maximum size macro to be executed in memory. Maximum value is 2,147,483,647.
specifies the maximum size macro to be executed in memory by a hexadecimal number followed by an X.
Use the MEXECSIZE option to control the maximum size macro that will be executed in memory as opposed to being executed from a file. The MEXECSIZE option value is the compiled size of the macro. Memory is allocated only when the macro is executed. After the macro completes, the memory is released. If memory is not available to execute the macro, an out-of-memory message is written to the SAS log. Use the MCOMPILENOTE option to write to the SAS log the size of the compiled macro. The MEMSIZE option does not affect the MEXECSIZE option.
Specifies whether MPRINT output is routed to an external file.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMFILE |
Requirement: |
MPRINT option |
See: |
MFILE | NOMFILE
MFILE
routes output produced by the MPRINT option to an external file. This option is useful for debugging.
NOMFILE
does not route MPRINT output to an external file.
The MPRINT option must also be in effect to use MFILE, and an external file must be assigned the fileref MPrint. Macro-generated code that is displayed by the MPRINT option in the SAS log during macro execution is written to the external file referenced by the fileref MPrint.
If MPrint is not assigned as a fileref or if the file cannot be accessed, warnings are written to the SAS log and MFILE is set to off. To use the feature again, you must specify MFILE again and assign the fileref MPrint to a file that can be accessed.
Specifies the character to be used as the delimiter for the macro IN operator.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
a blank |
Restriction: |
The following characters cannot be used as a delimiter % & ’ " ( ) ; |
See: |
“MINOPERATOR System Option” on page 355 and “%MACRO Statement” on page 315 |
MINDELIMITER="option"
option
is a character enclosed in double or single quotation marks. The character will be used as the delimiter for the macro IN operator. Here is an example:
double quotation marks
mindelimiter=",";
or single quotation marks
mindelimiter=',';
Restriction |
The following characters cannot be used as a delimiter |
|
% & ’ " ( ) ; |
The option value is retained in original case and can have a maximum length of one character. The default value of the MINDELIMITER option is a blank.
You can use the # character instead of IN.
Note: When the IN or # operator is used in a macro, the delimiter that is used at the execution time of the macro is the value of the MINDELIMITER option at the time of the compilation of the macro. A specific delimiter value for use during the execution of the macro other than the current value of the MINDELIMITER system option might be specified on the macro definition statement:
%macro macroname / mindelimiter=',';
The following is an example using a specified delimiter in an IN operator:
%put %eval(a in d,e,f,a,b,c); /* should print 0 */
%put %eval(a in d e f a b c); /* should print 1 */
option mindelimiter=',';
%put %eval(a in d,e,f,a,b,c); /* should print 1 */
%put %eval(a in d e f a b c); /* should print 0 */
The following is the output to the SAS log:
NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1B0)
Licensed to SAS Institute Inc., Site 1.
NOTE: This session is executing on the W32_7PRO platform.
NOTE: SAS initialization used:
real time 1.02 seconds
cpu time 0.63 seconds
%put %eval(a in d,e,f,a,b,c); /* should print 0 */
0
%put %eval(a in d e f a b c); /* should print 1 */
1
option mindelimiter=',';
%put %eval(a in d,e,f,a,b,c); /* should print 1 */
1
%put %eval(a in d e f a b c); /* should print 0 */
0
Controls whether the macro processor recognizes and evaluates the IN (#) logical operator.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMINOPERATOR |
Note: |
In order to use the macro IN operator in an expression, you must ensure that the MINOPERATOR system option has been changed from its default value of NOMINOPERATOR to MINOPERATOR. For more information, see MINOPERATOR system option on page 355 and “%MACRO Statement” on page 315. |
MINOPERATOR | NOMINOPERATOR
MINOPERATOR
causes the macro processor to recognize and evaluate both the mnemonic operator IN or the special character # as a logical operator in expressions.
causes the macro processor to recognize both the mnemonic operator IN and the special character # as regular characters.
Use the MINOPERATOR system option or in the %MACRO statement if you want to use the IN (#) as operators in expressions:
options minoperator;
To use IN or # as operators in expressions evaluated during the execution of a specific macro, use the MINOPERATOR keyword on the definition of the macro:
%macro macroname / minoperator;
The macro IN operator is similar to the DATA step IN operator, but not identical. The following is a list of differences:
• The macro IN operator cannot search a numeric array.
• The macro IN operator cannot search a character array.
• A colon (:) is not recognized as a shorthand notation to specify a range, such as 1:10 means 1 through 10. Instead, you use the following in a macro: %eval(3 in 1 2 3 4 5 6 7 8 9 10);
• The default delimiter for list elements is a blank. For more information, see “MINDELIMITER= System Option” on page 354.
• Both operands must contain a value.
%put %eval(a IN a b c d); /*Both operands are present. */
If an operand contains a null value, an error is generated.
%put %eval( IN a b c d); /*Missing first operand. */
or
%put %eval(a IN); /*Missing second operand. */
Whether the first or second operand contains a null value, the same error is written to the SAS log:
ERROR: Operand missing for IN operator in argument to %EVAL function.
The following example uses the macro IN operator to search a character string:
%if &state in (NY NJ PA) %then %let ®ion = %eval(®ion + 1);
For more information, see “Defining Arithmetic and Logical Expressions” on page 76.
Specifies whether the macro processor traces its execution for debugging.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO LOGCONTROL |
Type: |
System option |
Default: |
NOMLOGIC |
See: |
“The SAS Log” in Chapter 9 of SAS Language Reference: Concepts |
MLOGIC | NOMLOGIC
MLOGIC
causes the macro processor to trace its execution and to write the trace information to the SAS log. This option is a useful debugging tool.
NOMLOGIC
does not trace execution. Use this option unless you are debugging macros.
Use MLOGIC to debug macros. Each line generated by the MLOGIC option is identified with the prefix MLOGIC(macro-name):. If MLOGIC is in effect and the macro processor encounters a macro invocation, the macro processor displays messages that identify the following:
• the beginning of macro execution
• values of macro parameters at invocation
• execution of each macro program statement
• whether each %IF condition is true or false
• the ending of macro execution
Note: Using MLOGIC can produce a great deal of output.
For more information about macro debugging, see “Macro Facility Error Messages and Debugging” on page 124.
In this example, MLOGIC traces the execution of the macros MKTITLE and RUNPLOT:
%macro mktitle(proc,data);
title "%upcase(&proc) of %upcase(&data)";
%mend mktitle;
%macro runplot(ds);
%if %sysprod(graph)=1 %then
%do;
%mktitle (gplot,&ds)
proc gplot data=&ds;
plot style*price
/ haxis=0 to 150000 by 50000;
run;
quit;
%end;
%else
%do;
%mktitle (plot,&ds)
proc plot data=&ds;
plot style*price;
run;
quit;
%end;
%mend runplot;
options mlogic;
%runplot(Sasuser.Houses)
When this program executes, this MLOGIC output is written to the SAS log:
MLOGIC(RUNPLOT): Beginning execution.
MLOGIC(RUNPLOT): Parameter DS has value sasuser.houses
MLOGIC(RUNPLOT): %IF condition %sysprod(graph)=1 is TRUE
MLOGIC(MKTITLE): Beginning execution.
MLOGIC(MKTITLE): Parameter PROC has value gplot
MLOGIC(MKTITLE): Parameter DATA has value sasuser.houses
MLOGIC(MKTITLE): Ending execution.
MLOGIC(RUNPLOT): Ending execution.
Specifies whether to display the macro nesting information in the MLOGIC output in the SAS log.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO LOGCONTROL |
Type: |
System option |
Default: |
NOMLOGICNEST |
See: |
“The SAS Log” in Chapter 9 of SAS Language Reference: Concepts |
MLOGICNEST | NOMLOGICNEST
MLOGICNEST
enables the macro nesting information to be displayed in the MLOGIC output in the SAS log.
NOMLOGICNEST
prevents the macro nesting information from being displayed in the MLOGIC output in the SAS log.
MLOGICNEST enables the macro nesting information to be written to the SAS log in the MLOGIC output.
The setting of MLOGICNEST does not affect the output of any currently executing macro.
The setting of MLOGICNEST does not imply the setting of MLOGIC. You must set both MLOGIC and MLOGICNEST in order for output (with nesting information) to be written to the SAS log.
The first example shows both the MLOGIC and MLOGICNEST options being set:
%macro outer;
%put THIS IS OUTER;
%inner;
%mend outer;
%macro inner;
%put THIS IS INNER;
%inrmost;
%mend inner;
%macro inrmost;
%put THIS IS INRMOST;
%mend;
options mlogic mlogicnest;
%outer
Here is the MLOGIC output in the SAS log using the MLOGICNEST option:
MLOGIC(OUTER): Beginning execution.
MLOGIC(OUTER): %PUT THIS IS OUTER
THIS IS OUTER
MLOGIC(OUTER.INNER): Beginning execution.
MLOGIC(OUTER.INNER): %PUT THIS IS INNER
THIS IS INNER
MLOGIC(OUTER.INNER.INRMOST): Beginning execution.
MLOGIC(OUTER.INNER.INRMOST): %PUT THIS IS INRMOST
THIS IS INRMOST
MLOGIC(OUTER.INNER.INRMOST): Ending execution.
MLOGIC(OUTER.INNER): Ending execution.
MLOGIC(OUTER): Ending execution.
The second example uses only the NOMLOGICNEST option:
%macro outer;
%put THIS IS OUTER;
%inner;
%mend outer;
%macro inner;
%put THIS IS INNER;
%inrmost;
%mend inner;
%macro inrmost;
%put THIS IS INRMOST;
%mend;
options nomlogicnest;
%outer
Here is the output in the SAS log when you use only the NOMLOGICNEST option:
MLOGIC(OUTER): Beginning execution.
MLOGIC(OUTER): %PUT THIS IS OUTER
THIS IS OUTER
MLOGIC(INNER): Beginning execution.
MLOGIC(INNER): %PUT THIS IS INNER
THIS IS INNER
MLOGIC(INRMOST): Beginning execution.
MLOGIC(INRMOST): %PUT THIS IS INRMOST
THIS IS INRMOST
MLOGIC(INRMOST): Ending execution.
MLOGIC(INNER): Ending execution.
MLOGIC(OUTER): Ending execution.
Specifies whether SAS statements generated by macro execution are traced for debugging.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO LOGCONTROL |
Type: |
System option |
Default: |
NOMPRINT |
See: |
“MFILE System Option” on page 353 and “The SAS Log” in Chapter 9 of SAS Language Reference: Concepts |
MPRINT | NOMPRINT
MPRINT
displays the SAS statements that are generated by macro execution. The SAS statements are useful for debugging macros.
NOMPRINT
does not display SAS statements that are generated by macro execution.
The MPRINT option displays the text generated by macro execution. Each SAS statement begins a new line. Each line of MPRINT output is identified with the prefix MPRINT(macro-name):, to identify the macro that generates the statement. Tokens that are separated by multiple spaces are printed with one intervening space.
You can direct MPRINT output to an external file by also using the MFILE option and assigning the fileref MPrint to that file. For more information, see “MFILE System Option” on page 353.
Example 1: Tracing Generation of SAS Statements
In this example, MPRINT traces the SAS statements that are generated when the macros MKTITLE and RUNPLOT execute:
%macro mktitle(proc,data);
title "%upcase(&proc) of %upcase(&data)";
%mend mktitle;
%macro runplot(ds);
%if %sysprod(graph)=1 %then
%do;
%mktitle (gplot,&ds)
proc gplot data=&ds;
plot style*price
/ haxis=0 to 150000 by 50000;
run;
quit;
%end;
%else
%do;
%mktitle (plot,&ds)
proc plot data=&ds;
plot style*price;
run;
quit;
%end;
%mend runplot;
options mprint;
%runplot(Sasuser.Houses)
When this program executes, this MPRINT output is written to the SAS log:
MPRINT(MKTITLE): TITLE "GPLOT of SASUSER.HOUSES";
MPRINT(RUNPLOT): PROC GPLOT DATA=SASUSER.HOUSES;
MPRINT(RUNPLOT): PLOT STYLE*PRICE / HAXIS=0 TO 150000 BY 50000;
MPRINT(RUNPLOT): RUN;
MPRINT(RUNPLOT): QUIT;
Example 2: Directing MPRINT Output to an External File
Adding these statements before the macro call in the previous program sends the MPRINT output to the file DebugMac when the SAS session ends.
options mfile mprint;
filename mprint 'debugmac';
Specifies whether to display the macro nesting information in the MPRINT output in the SAS log.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMPRINTNEST |
MPRINTNEST | NOMPRINTNEST
MPRINTNEST
enables the macro nesting information to be displayed in the MPRINT output in the SAS log.
NOMPRINTNEST
prevents the macro nesting information from being displayed in the MPRINT output in the SAS log.
MPRINTNEST enables the macro nesting information to be written to the SAS log in the MPRINT output. The MPRINTNEST output has no effect on the MPRINT output that is sent to an external file. For more information, see MFILE System Option.
The setting of MPRINTNEST does not imply the setting of MPRINT. You must set both MPRINT and MPRINTNEST in order for output (with the nesting information) to be written to the SAS log.
The following example uses the MPRINT and MPRINTNEST options:
%macro outer;
data _null_;
%inner
run;
%mend outer;
%macro inner;
put %inrmost;
%mend inner;
%macro inrmost;
'This is the text of the PUT statement'
%mend inrmost;
options mprint mprintnest;
%outer
Here is the output written to the SAS log using both the MPRINT option and the MPRINTNEST option:
MPRINT(OUTER): data _null_;
MPRINT(OUTER.INNER): put
MPRINT(OUTER.INNER.INRMOST): 'This is the text of the PUT statement'
MPRINT(OUTER.INNER): ;
MPRINT(OUTER): run;
This is the text of the PUT statement
NOTE: DATA statement used (Total process time):
real time 0.10 seconds
cpu time 0.06 seconds
Here is an example that uses the NOMPRINTNEST option:
%macro outer;
data _null_;
%inner
run;
%mend outer;
%macro inner;
put %inrmost;
%mend inner;
%macro inrmost;
'This is the text of the PUT statement'
%mend inrmost;
options nomprintnest;
%outer
Here is the output written to the SAS log using the NOMPRINTNEST option:
MPRINT(OUTER): data _null_;
MPRINT(INNER): put
MPRINT(INRMOST): 'This is the text of the PUT statement'
MPRINT(INNER): ;
MPRINT(OUTER): run;
This is the text of the PUT statement
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
Specifies whether autocall libraries are searched for a member that was not found during an earlier search.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMRECALL |
MRECALL | NOMRECALL
MRECALL
searches the autocall libraries for an undefined macro name each time an attempt is made to invoke the macro. It is inefficient to search the autocall libraries repeatedly for an undefined macro. Generally, use this option when you are developing or debugging programs that call autocall macros.
NOMRECALL
searches the autocall libraries only once for a requested macro name.
Use the MRECALL option primarily for
• developing systems that require macros in autocall libraries.
• recovering from errors caused by an autocall to a macro that is in an unavailable library. Use MRECALL to call the macro again after making the library available. In general, do not use MRECALL unless you are developing or debugging autocall macros.
Specifies whether to enable existing macros to be redefined.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
MREPLACE |
MREPLACE | NOMREPLACE
MREPLACE
enables you to redefine existing macro definitions that are stored in a catalog in the Work library.
NOMREPLACE
prevents you from redefining existing macro definitions that are stored in a catalog in the Work library.
The MREPLACE system option enables you to overwrite existing macros if the names are the same.
The NOMREPLACE system option prevents you from overwriting a macro even if a macro with the same name has already been compiled.
Specifies whether the macro facility searches a specific catalog for a stored compiled macro.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Default: |
NOMSTORED |
MSTORED | NOMSTORED
MSTORED
searches for stored compiled macros in a catalog in the SAS library referenced by the SASMSTORE= option.
NOMSTORED
does not search for compiled macros.
Regardless of the setting of MSTORED, the macro facility first searches for macros compiled in the current SAS session. If the MSTORED option is in effect, the macro facility next searches the libraries containing compiled stored macros. If the MAUTOSOURCE option is in effect, the macro facility next searches the autocall libraries. Then, the macro facility searches the SASMacr catalog in the SASHelp library.
Specifies the maximum amount of memory available to the macro variable symbol table or tables.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
MSYMTABMAX= n | nK | nM | nG | MAX
n
specifies the maximum memory available in bytes.
nK
specifies the maximum memory available in kilobytes.
nM
specifies the maximum memory available in megabytes.
nG
specifies the maximum memory available in gigabytes.
MAX
specifies the maximum memory of 65534.
Once the maximum value is reached, additional macro variables are written out to disk.
The value that you specify with the MSYMTABMAX= system option can range from 0 to the largest nonnegative integer representable on your operating environment. The default values are host dependent. A value of 0 causes all macro symbol tables to be written to disk.
The value of MSYMTABMAX= can affect system performance. If this option is set too low and the application frequently reaches the specified memory limit, then disk I/O increases. If this option is set too high (on some operating environments) and the application frequently reaches the specified memory limit, then less memory is available for the application, and CPU usage increases. Before you specify the value for production jobs, run tests to determine the optimum value.
Specifies the maximum size for macro variable values that are stored in memory.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
MVARSIZE=n | nK | nM | nG | MAX
n
specifies the maximum memory available in bytes.
nK
specifies the maximum memory available in kilobytes.
nM
specifies the maximum memory available in megabytes.
nG
specifies the maximum memory available in gigabytes.
MAX
specifies the maximum memory of 65534.
If the memory required for a macro variable value is larger than the MVARSIZE= value, the variable is written to a temporary catalog on disk. The macro variable name is used as the member name, and all members have the type MSYMTAB.
The value that you specify with the MVARSIZE= system option can range from 0 to 65534. A value of 0 causes all macro variable values to be written to disk.
The value of MVARSIZE= can affect system performance. If this option is set too low and the application frequently creates macro variables larger than the limit, then disk I/O increases. Before you specify the value for production jobs, run tests to determine the optimum value.
Note: The MVARSIZE= option has no affect on the maximum length of the value of the macro variable. For more information, see “Macro Variables” on page 21.
Specifies the location of one or more autocall libraries.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
ENVFILES MACRO |
Type: |
System option |
Default: |
SASAUTOS |
SASAUTOS= library-specification |
(library-specification-1, library-specification-2, …)
library-specification
identifies a location that contains library members that contain a SAS macro definition. A location can be a SAS fileref or a host-specific location name enclosed in quotation marks. Each member contains a SAS macro definition.
(library-specification-1, library-specification-2, ...)
identifies two or more locations that contain library members that contain a SAS macro definition. A location can be a SAS fileref or a host-specific location name enclosed in quotation marks. When you specify two or more autocall libraries, enclose the specifications in parentheses and separate them with either a comma or a blank space.
SAS automatically generates a fileref named SASAUTOS. This is the default value of the SASAUTOS= option and points to all the SAS autocall macros. If the value of SASAUTOS= is overwritten, then SAS no longer knows where to locate its own autocall macros. When you specify the value of the SASAUTOS= system option, list the fileref SASAUTOS first, followed by the location of other autocall libraries. This enables SAS to locate the SAS autocall macros as well as any autocall macros that you have defined.
When SAS searches for an autocall macro definition, it opens and searches each location in the same order that it is specified in the SASAUTOS option. If SAS cannot open any specified location, it generates a warning message and sets the NOMAUTOSOURCE system option on. To use the autocall facility again in the same SAS session, you must specify the MAUTOSOURCE option again. Also see “MRECALL System Option” on page 363, which searches the autocall libraries for an undefined macro name each time an attempt is made to invoke the macro.
Note: When searching the list of library specifications for an autocall macro definition, SAS silently ignores library access failures due to insufficient access privileges and continues to search through the list of library specifications.
Operating Environment Information
You specify a source library by using a fileref or by enclosing the host-specific location name in quotation marks. A valid library specification and its syntax are host specific. Although the syntax is generally consistent with the command-line syntax of your operating environment, it might include additional or alternate punctuation. For details, see the SAS documentation for your operating environment.
z/OS Specifics
You can use the APPEND or INSERT system options to add additional library-specification. For details, see the documentation for the APPEND and INSERT system options under UNIX and z/OS.
Identifies the libref of a SAS library with a catalog that contains, or will contain, stored compiled SAS macros.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
SASMSTORE=libref
libref
specifies the libref of a SAS library that contains, or will contain, a catalog of stored compiled SAS macros. This libref cannot be Work.
Specifies whether the macro processor issues a warning message when a macro variable reference does not match a macro variable.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS GROUP= |
MACRO |
Type: |
System option |
Alias: |
SERR | NOSERR |
Default: |
SERROR |
SERROR | NOSERROR
SERROR
issues a warning message when the macro processor cannot match a macro variable reference to an existing macro variable.
NOSERROR
issues no warning messages when the macro processor cannot match a macro variable reference to an existing macro variable.
Several conditions can occur that prevent a macro variable reference from resolving. These conditions appear when one or more of the following is true:
• the name in a macro variable reference is misspelled.
• the variable is referenced before being defined.
• the program contains an ampersand ( &) followed by a string, without intervening blanks between the ampersand and the string. For example:
if x&y then do;
if buyer="Smith&Jones, Inc." then do;
If your program uses a text string containing ampersands and you want to suppress the warnings, specify NOSERROR.
Specifies whether the results of resolving macro variable references are written to the SAS log for debugging.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
PROC OPTIONS |
MACRO |
GROUP= |
LOGCONTROL |
Type: |
System option |
Alias: |
SGEN | NOSGEN |
Default: |
NOSYMBOLGEN |
See: |
“The SAS Log” in Chapter 9 of SAS Language Reference: Concepts |
SYMBOLGEN | NOSYMBOLGEN
SYMBOLGEN
displays the results of resolving macro variable references. This option is useful for debugging.
NOSYMBOLGEN
does not display results of resolving macro variable references.
SYMBOLGEN displays the results in this form:
SYMBOLGEN: Macro variable name resolves to value
SYMBOLGEN also indicates when a double ampersand (&&) resolves to a single ampersand (&).
In this example, SYMBOLGEN traces the resolution of macro variable references when the macros MKTITLE and RUNPLOT execute:
%macro mktitle(proc,data);
title "%upcase(&proc) of %upcase(&data)";
%mend mktitle;
%macro runplot(ds);
%if %sysprod(graph)=1 %then
%do;
%mktitle (gplot,&ds)
proc gplot data=&ds;
plot style*price
/ haxis=0 to 150000 by 50000;
run;
quit;
%end;
%else
%do;
%mktitle (plot,&ds)
proc plot data=&ds;
plot style*price;
run;
quit;
%end;
%mend runplot;
%runplot(Sasuser.Houses)
When this program executes, this SYMBOLGEN output is written to the SAS log:
SYMBOLGEN: Macro variable DS resolves to sasuser.houses
SYMBOLGEN: Macro variable PROC resolves to gplot
SYMBOLGEN: Macro variable DATA resolves to sasuser.houses
SYMBOLGEN: Macro variable DS resolves to sasuser.houses
Specifies a character string that can be passed to SAS programs.
Valid in: |
Configuration file, OPTIONS window, OPTIONS statement, SAS invocation |
Category: |
Macro |
Type: |
System option |
SYSPARM=’character-string’
character-string
is a character string, enclosed in quotation marks, with a maximum length of 200.
The character string specified can be accessed in a SAS DATA step by the SYSPARM() function or anywhere in a SAS program by using the automatic macro variable reference &SYSPARM.
Operating Environment Information
The syntax shown here applies to the OPTIONS statement. At invocation, on the command line, or in a configuration file, the syntax is host specific. For details, see the SAS documentation for your operating environment.
This example uses the SYSPARM option to pass a user identification to a program.
options sysparm='usr1';
data a;
length z $100;
if sysparm()='usr1' then z="&sysparm";
run;
3.145.45.5