Chapter Contents

Previous

Next
%LET

%LET



Creates a macro variable and assigns it a value

Type: Macro statement
Restriction: Allowed in macro definitions or open code
See also: %STR and %NRSTR


Syntax
Details
Example
Sample %LET Statements

Syntax

%LET macro-variable =<value>;

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

Example 1: Sample %LET Statements

These examples illustrate several %LET statement:

%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";


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.