%SYSMEXECNAME Function

Returns the name of the macro executing at a requested nesting level.
Type: Macro Function
Tip: %SYSMEXECNAME and %SYSMEXECDEPTH were implemented to be used together, but it is not required.
See: %SYSMEXECDEPTH function

Syntax

%SYSMEXECNAME (n)

Required Argument

n
The nesting level at which you are requesting the macro name.
0 open code
>0 nesting level

Details

The %SYSMEXECNAME function returns the name of the macro executing at the n nesting level. The following three scenarios are shown in the example below.
  • If n = 0, open code is returned.
  • If n >%SYSMEXECDEPTH, a null string is returned and a WARNING diagnostic message is issued to the SAS log.
  • If n<0, a null string is returned and a WARNING diagnostic message is issued to the SAS log.
3          %put %sysmexecdepth; /* The macro execution depth of 
                                   Open Code is zero */
0
4          %put %sysmexecname(%sysmexecdepth);
OPEN CODE
5          %put %sysmexecname(%sysmexecdepth + 1);
WARNING: Argument 1 to %SYSMEXECNAME function is out of range.

6          %put %sysmexecname(%sysmexecdepth - 1);
WARNING: Argument 1 to %SYSMEXECNAME function is out of range.