%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

Syntax

%LET macro-variable =<value> ;

Required Arguments

macro-variable
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.
value
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.

Details

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";
%mend;
%let topic=  The History of Genetics  ; /* Leading and trailing */
                                        /* blanks are removed   */
%title(&topic,1)
%let subject=topic;                     /* &subject resolves    */
%let &subject=Genetics Today;           /* before assignment    */
%title(&topic,2)
%let subject=The Future of Genetics;    /* &subject resolves    */
%let topic= &subject;                   /* before assignment    */
%title(&topic,3)
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";