Search notes:

SAS: macro variables

Macro variables start with an ampersand (&).
A macro variable does not belong to a data set.
The data type of a macro variable is character up to 64'000 characters.
If a macro variable is defined in a macro, it's scope is local. If it is defined in open code, its scope is global.
Within single quotes, macro variables are not expanded.
Macro variables are defined with the %let macro statement:
%let macro_variable=value;
Macro variables can later be deleted/undefined with %symdel.
Within a data step, a macro variable can be created with symput.
The (value of) macro variables are stored in the macro table.
A macro variable's value is resolved when it reaches the top of the input stack.
Within proc sql, a macro variable can be assigned with the select into clause.

Listing macro variables

%put _all_;
%put _user_;
The dictionary table macros can be used to show existing macros:
%let tq84_macro_var = Hello world;

proc sql;
  select
    scope,  /* GLOBAL, LOCAL ?...         */
    offset, /* Offset into macro variable */
    value
  from
    dictionary.macros
  where
    name = 'TQ84_MACRO_VAR';
quit;
Github repository about-SAS, path: /macro-processor/dictionary.macros.sas

See also

macros
automatic macro variables
Indirect reference (Using &&&)
SAS macro variables: local and global

Index