Wednesday, July 20, 2011

SAS 9.3 Macro Language Features for Context

SAS 9.3 adds macro functions, macro statements, and automatic macro variables to allow macro language programming to have more contextual awareness.

The new macro functions and macro statements have to do with macros in the current session. The %SYSMACEXIST and %SYSMACEXEC functions search for a macro by name, telling you whether the macro has been defined in the current session and whether it is currently executing. The %SYSMEXECDEPTH and %SYSMEXECNAME functions allow you to discover the names of all currently executing macros.

The %SYSMACDELETE statement deletes macros from the current session. The %SYSMSTORECLEAR statement closes the stored compiled macro library. Both statements have to be used with care; you cannot delete a currently running macro, nor can you deassign a stored compiled macro library if one if its macros is running.

The new automatic macro variables allow you to write SAS code that adjusts for the sizes of objects, along with a few related considerations. SYSSIZEOFLONG, SYSADDRBITS, SYSSIZEOFPTR, and SYSSIZEOFUNICODE indicate the size of a long integer, address, pointer, and Unicode character, respectively. SYSENDIAN provides the byte sequence of numeric values.

Another new automatic macro variable, SYSODSESCAPECHAR, tells you the ODS escape character. Using this macro variable, you can add the ODS escape character to a string, or check for (and encode) escape character conflicts in character data, without having to know what the escape character is.

No comments:

Post a Comment