%LET Statement

Creates a macro variable and assigns it a value.
Type: Macro statement
Restriction: Allowed in macro definitions or open code
See: %STR and %NRSTR Functions


%LET macro-variable =<value> ;

Required Arguments

is either the name of a macro variable or a text expression that produces a macro variable name. The name can refer to a new or existing macro variable.
is a character string or a text expression. Omitting value produces a null value (0 characters). Leading and trailing blanks in value are ignored. To make them significant, enclose value with the %STR function.


If the macro variable named in the %LET statement already exists, the %LET statement changes the value. A %LET statement can define only one macro variable at a time.

Example: Sample %LET Statements

These examples illustrate several %LET statements:
%macro title(text,number);
    title&number "&text";
%let topic=  The History of Genetics  ; /* Leading and trailing */
                                        /* blanks are removed   */
%let subject=topic;                     /* &subject resolves    */
%let &subject=Genetics Today;           /* before assignment    */
%let subject=The Future of Genetics;    /* &subject resolves    */
%let topic= &subject;                   /* before assignment    */
When you submit these statements, the TITLE macro generates the following statements:
TITLE1 "The History of Genetics";
TITLE2 "Genetics Today";
TITLE3 "The Future of Genetics";