Chapter Contents |
Previous |
Next |
SAS Macro Language: Reference |
When you define macro variables, you can include macro functions in the expressions to manipulate the value of the variable before the value is stored. For example, you can use functions that scan other values, evaluate arithmetic and logical expressions, and remove the significance of special characters such as unmatched quotation marks.
To scan for words in macro variable values, use the %SCAN function. For example,
%let address=123 maple avenue; %let frstword=%scan(&address,1);
The first %LET statement assigns the string
123 maple avenue
to macro
variable ADDRESS. The second %LET statement uses the %SCAN function to search
the source (first argument) and retrieve the first word (second argument).
Because the macro processor executes the %SCAN function before it stores the
value, the value of FRSTWORD is the string
123
. (The %SCAN function
is discussed in Chapter 13.)
For more information about macro functions, see "Macro Functions" in Chapter 12.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.