Enabling ARM Macro Execution


Setting the _ARMEXEC Macro Variable

All ARM macros are disabled by default so that insertion of ARM macros within created code will not result in inadvertent, unwanted logging. To globally activate execution of the ARM macros, you must set the _ARMEXEC global macro variable to a value of 1. Any other value for _ARMEXEC disables the ARM macros.

There are two methods of setting the _ARMEXEC macro variable. The first method sets the variable during DATA step or SCL program compilation using %LET:

 %let _armexec = 1; 

If the _ARMEXEC value is not set to 1, then no code is generated and a message is written in the log:

 NOTE: ARMSTRT macro bypassed by _armexec. 

The second method of setting _ARMEXEC variables is to use SYMPUT during execution. To set the _ARMEXEC variable during DATA step or SCL program execution:

 call symput('_armexec', '1'); 

With this technique, the macro checks the _ARMEXEC variable during program execution and the ARM function call is executed or bypassed as appropriate.

Enabling ARM Macro Execution with SCL

There are two methods of setting the _ARMEXEC macro variable-during compilation or execution. Both methods are explained in 'Setting the _ARMEXEC Macro Variable' on page 1061, or you can use a combination of these methods. For example, set _ARMEXEC to 1 using the compilation technique (perhaps in an autoexec at SAS initialization), and then code a drop-down menu option or other means within the application to turn _ARMEXEC on and off dynamically using CALL SYMPUT.

In SCL, if _ARMEXEC is not 1, when the program compiles, all macros will be set to null and the ARM interface will be unavailable until it is recompiled with _ARMEXEC set to 1.

Additionally, to enable proper compilation of the ARM macros within SCL, you must set the _ARMSCL global macro variable to 1 prior to issuing any ARM macros. This variable suppresses the generation of DROP statements, which are invalid in SCL.

Conditional ARM Macro Execution

It is useful to code the ARM macros in your program but to execute them only when needed. All ARM macros support a LEVEL= option that specifies the execution level of that particular macro.

If it is coded, the execution level of the macro is compared to two global macro variables, _ARMGLVL and _ARMTLVL. _ARMGLVL is the global level macro variable. If the LEVEL= value on the ARM macro is less than or equal to the _ARMGLVL value, then the macro is executed. If the LEVEL= value on the ARM macro is greater than the _ARMGLVL value, then macro execution is bypassed:

 /*  Set the global level to 10 */    %let _armglvl = 10;  data _null_;    %arminit(appname='Appl 1', appuser='userid' );    %armgtid(txnname='Txn 1', txndet='Transaction #1 detail' );      /*  These macros are executed */    %armstrt( level=9 );    %armstop( level=9 );      /*  These macros are executed */    %armstrt( level=10 );    %armstop( level=10 );      /*  These macros are NOT executed */    %armstrt( level=11 );    %armstop( level=11 );    %armend  run; 

_ARMTLVL is the target level macro variable and works similarly to the ARMGLVL, except the LEVEL= value on the ARM macro must be exactly equal to the _ARMTLVL value for the macro to execute:

 /*  Set the target level to 10 */    %let _armtlvl = 10;  data _null_;    %arminit(appname='Appl 1', appuser='userid' );    %armgtid(txnname='Txn 1', txndet='Transaction #1 detail' );      /*  These macros are NOT executed */    %armstrt( level=9 );    %armstop( level=9 );      /*  These macros are executed */    %armstrt( level=10 );    %armstop( level=10 );      /*  These macros are NOT executed */    %armstrt( level=11 );    %armstop( level=11 );    %armend  run; 

The LEVEL= option can be placed on any ARM macro and this is highly recommended. It allows you to design more granular levels of logging that can serve as an effective filtering device by logging only as much data as you want. If you set both _ARMGLVL and _ARMTLVL at the same time, then both values are compared to determine whether the macro should be executed or not.




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net