%SYSFUNC macro function

From sasCommunity
Jump to: navigation, search
This is a work in progress. You are welcome to contribute to this article.

%SYSFUNC is a macro function that enables macro code to access and evaluate many, (though not all), SAS functions.

Syntax

%SYSFUNC( function(...) <,format> )

where

  • function(...) is the SAS function to be called, complete with parameters.
  • <,format> is an optional format for formatting the result of the SAS function.

Usage

Because %SYSFUNC is a macro function and is interpreted in the macro processor, the input parameters to the called function are treated as text. While text that represents numeric constants will be converted to numeric input values if that is what the called function requires, nested functions must be enclosed in a nested %SYSFUNC call. Conversely, if the called function expects text or alphanumeric input parameters then the text should not be enclosed in quotes as the quotes will be passed to the called function too.

The results of the function called by %SYSFUNC are returned as text, which can be formatted by an optional format parameter.

Error messages

%SYSFUNC may raise an ERROR condition when the called function returns a missing value or cannot be evaluated.

 ERROR: An error occurred while executing function MAX referenced by the %SYSFUNC or %QSYSFUNC
        macro function.
 NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The
       result of the operations have been set to a missing value.

See also

References