Chapter 20

System Options for Macros

System Options for Macros

Dictionary

CMDMAC System Option

IMPLMAC System Option

MACRO System Option

MAUTOCOMPLOC System Option

MAUTOLOCDISPLAY System Option

MAUTOLOCINDES System Option

MAUTOSOURCE System Option

MCOMPILENOTE System Option

MCOMPILE System Option

MCOVERAGE System Options

MCOVERAGELOC= System Option

MERROR System Option

MEXECNOTE System Option

MEXECSIZE System Option

MFILE System Option

MINDELIMITER= System Option

MINOPERATOR System Option

MLOGIC System Option

MLOGICNEST System Option

MPRINT System Option

MPRINTNEST System Option

MRECALL System Option

MREPLACE System Option

MSTORED System Option

MSYMTABMAX= System Option

MVARSIZE= System Option

SASAUTOS= System Option

SASMSTORE= System Option

SERROR System Option

SYMBOLGEN System Option

SYSPARM= System Option

System Options for Macros

There are several SAS system options that apply to the macro facility.

Dictionary

CMDMAC System Option

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

Syntax

CMDMAC | NOCMDMAC

Required Arguments

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.

Details

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.

Comparisons

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.

IMPLMAC System Option

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

Syntax

IMPLMAC | NOIMPLMAC

Required Arguments

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.

Details

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.

Comparisons

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.

MACRO System Option

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

Syntax

MACRO | NOMACRO

Required Arguments

MACRO

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.

MAUTOCOMPLOC System Option

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

Syntax

MAUTOCOMPLOC | NOMAUTOCOMPLOC

Required Arguments

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.

Details

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.

MAUTOLOCDISPLAY System Option

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

Syntax

MAUTOLOCDISPLAY | NOMAUTOLOCDISPLAY

Required Arguments

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.

Details

When both MAUTOLOCDISPLAY and MLOGIC options are set, only the MLOGIC listing of the autocall source location is displayed.

MAUTOLOCINDES System Option

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

Syntax

MAUTOLOCINDES | NOMAUTOLOCINDES

Required Arguments

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.

Details

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

MAUTOSOURCE System Option

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

Syntax

MAUTOSOURCE | NOMAUTOSOURCE

Required Arguments

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.

Details

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.

MCOMPILENOTE System Option

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

Syntax

MCOMPILENOTE=NONE | NOAUTOCALL | ALL

Required Arguments

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.

Details

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.

Example: Using MCOMPILENOTE System Option

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.

MCOMPILE System Option

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

Syntax

MCOMPILE | NOMCOMPILE

Required Arguments

MCOMPILE

allows new macro definitions.

NOMCOMPILE

disallows new macro definitions.

Details

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.

MCOVERAGE System Options

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

Syntax

MCOVERAGE | NOMCOVERAGE

Required Arguments

MCOVERAGE

enables the generation of coverage analysis data.

NOMCOVERAGE

prevents the generation of coverage analysis data.

Details

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

macroname

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.

MCOVERAGELOC= System Option

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:

MCOVERAGE System Options” on page 347

Syntax

MCOVERAGELOC=fileref | file-specification

Required Argument

fileref | file-specification

a SAS fileref or an external file specification enclosed in quotation marks.

Details

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.

MERROR System Option

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

Syntax

MERROR | NOMERROR

Required Arguments

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.

Details

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.

MEXECNOTE System Option

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

Syntax

MEXECNOTE | NOMEXECNOTE

Required Arguments

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.

Details

The MEXECNOTE option controls the generation of a NOTE in the SAS log that indicates the macro execution mode.

MEXECSIZE System Option

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:

MEXECNOTE on page 351 and MCOMPILENOTE on page 345

Syntax

MEXECSIZE=n | nK | nM | nG | nT | hexX | MIN | MAX

Required Arguments

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.

hexX

specifies the maximum size macro to be executed in memory by a hexadecimal number followed by an X.

Details

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.

MFILE System 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:

MPRINT System Option” on page 360

Syntax

MFILE | NOMFILE

Required Arguments

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.

Details

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.

MINDELIMITER= System Option

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

Syntax

MINDELIMITER="option"

Required Argument

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

 

% & ’ " ( ) ;

Details

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=',';

Comparisons

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

MINOPERATOR System Option

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.

Syntax

MINOPERATOR | NOMINOPERATOR

Required Arguments

MINOPERATOR

causes the macro processor to recognize and evaluate both the mnemonic operator IN or the special character # as a logical operator in expressions.

NOMINOPERATOR

causes the macro processor to recognize both the mnemonic operator IN and the special character # as regular characters.

Details

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 &region = %eval(&region + 1);

For more information, see “Defining Arithmetic and Logical Expressions” on page 76.

MLOGIC System Option

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

Syntax

MLOGIC | NOMLOGIC

Required Arguments

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.

Details

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.

Example: Tracing Macro Execution

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.

MLOGICNEST System Option

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

Syntax

MLOGICNEST | NOMLOGICNEST

Required Arguments

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.

Details

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.

Example: Using MLOGICNEST System Option

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.

MPRINT System Option

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

Syntax

MPRINT | NOMPRINT

Required Arguments

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.

Details

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.

Examples

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';

MPRINTNEST System Option

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

Syntax

MPRINTNEST | NOMPRINTNEST

Required Arguments

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.

Details

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.

Example: Using MPRINTNEST System Option

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

MRECALL System Option

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

Syntax

MRECALL | NOMRECALL

Required Arguments

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.

Details

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.

MREPLACE System Option

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

Syntax

MREPLACE | NOMREPLACE

Required Arguments

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.

Details

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.

MSTORED System Option

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

Syntax

MSTORED | NOMSTORED

Required Arguments

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.

Details

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.

MSYMTABMAX= System Option

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

Syntax

MSYMTABMAX= n | nK | nM | nG | MAX

Required Arguments

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.

Details

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.

MVARSIZE= System Option

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

Syntax

MVARSIZE=n | nK | nM | nG | MAX

Required Arguments

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.

Details

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.

SASAUTOS= System Option

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

Syntax

SASAUTOS= library-specification |

(library-specification-1, library-specification-2, …)

Required Arguments

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.

Details

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.

SASMSTORE= System Option

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

Syntax

SASMSTORE=libref

Required Argument

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.

SERROR System Option

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

Syntax

SERROR | NOSERROR

Required Arguments

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.

Details

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.

SYMBOLGEN System Option

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

Syntax

SYMBOLGEN | NOSYMBOLGEN

Required Arguments

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.

Details

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 (&).

Example: Tracing Resolution of Macro Variable References

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

SYSPARM= System Option

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

Syntax

SYSPARM=character-string

Required Argument

character-string

is a character string, enclosed in quotation marks, with a maximum length of 200.

Details

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.

Example: Passing a User Identification to a Program

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;

..................Content has been hidden....................

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