SAS macro variable definitions

SAS Global macro variables can pass information between SAS data steps or SAS procedures. SAS macro variable definition can be assigned a value with the %LET statement, or they can be assigned the value of a SAS variable in a data step using the SYMPUT function. This freezes that value to be used in many places like titles, assignment of variables, or parameters to SAS macros.

One limitation of the SYMPUT function is that the length of the macro variable generated is the format length of the variable. The desired length of the macro variable is the length of the character string being assigned. This can result in including blank characters and losing characters due to truncation.

SAS Fifth Dimension Sugestions:



SAS System macro variables

SAS System macro variables have addtional functionality.


The SYSLAST system macro variable is set to the last used SAS file. It can be used as a data or set statement when necessary. Its most interesting function is that it can be set like any macro variable. In some macros it is important to save the value of macro variable SYSLAST upon invocation. Open or create SAS file as requried by the macro which would change the macro variable SYSLAST and restore the macro variable SYSLAST before ending the macro.

This technique prevents the macro from changing the SAS system environment.

For Example:the last used file is Your_SAS_file.
            your_SAS_macro is invoked
            Proc print is used without a data parameter 
                       to print Your_SAS_file 

If your_SAS_macro opened, create or used another SAS file, the proc print may not print Your_SAS_file.