Creates a macro variable and assigns it a value.
%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.
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.
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";
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.