Chapter Contents |
Previous |
Next |
SAS Macro Language: Reference |
Some macro functions are available in pairs, where one function starts with the letter Q:
The Qxxx functions are necessary because by default, macro functions return an unquoted result, even if the argument was masked by a macro quoting function. The %QSCAN, %QSUBSTR, %QUPCASE, and %QSYSFUNC functions mask the returned value. The items masked are the same as those masked by the %NRBQUOTE function.
Example Using the %QSCAN Function |
The following macro uses the %QSCAN function to assign items in the value of SYSBUFFR (described in Chapter 13) as the values of separate macro variables. The numbers in the comments correspond to the explanations in the list that follows the macro code.
%macro splitit; %put What character separates the values?; [1] %input; %let s=%bquote(&sysbuffr); [2] %put Enter three values.; %input; %local i; %do i=1 %to 3; [3] %global x&i; %let x&i=%qscan(%superq(sysbuffr),&i,&s); [4] %end; %mend splitit; %splitit What character separates the values? # Enter three values. Fischer Books#Smith&Sons#Sarah's Sweet Shoppe [5]
Sarah's Sweet Shoppe
and
the &name pattern in
Smith&Sons
do not cause
problems.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.