Quoting with %QSYSFUNC
As with macro character functions, if the argument for a %SYSFUNC
function contains special characters or mnemonic operators, you must use
the quoting version of the function. The %QSYSFUNC function
has the same syntax as the %SYSFUNC function. %QSYSFUNC
works the same as %SYSFUNC except that it also masks mnemonic
operators and special characters.
Example
Suppose
you want to create a report title that includes the current date in WORDDATE. format.
You could use this statement:
title "Report Produced on %sysfunc(today(),worddate.)";
However, that would result in the following title:
Report Produced on June 7, 2002
The extra blanks are from the default length of the WORDDATE. format.
You need to left justify the resulting formatted date. You cannot
nest functions within %SYSFUNC, but you can use
a %SYSFUNC for each function that you need, as shown in
this example:
title "Report Produced on
%sysfunc(left(%sysfunc(today(),worddate.)))";
However, this statement results in the following error message.
SAS Log
ERROR: The function LEFT referenced by the %SYSFUNC or
%QSYSFUNC macro function has too many arguments.
|
The LEFT function expects only one argument, but you are passing
"June 12, 2000" to it. It interprets the comma as the delimiter
between two arguments.
You can mask the comma by using the %QSYSFUNC
function instead, as follows:
title "Report Produced on
%sysfunc(left(%qsysfunc(today(),worddate.)))";
The modified statement generates the following title:
Report Produced on June 7, 2002
|