As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

SYSFUNC and Missing Values

From sasCommunity
Revision as of 01:14, 9 July 2017 by Cameron (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

%SYSFUNC appears to incorrectly raise an ERROR condition when the called function returns a missing value.

First consider the results of two calls to the MAX function in a DATA step:

 data _null_;
 result = max(1,.); put 'max(1,.) is ' result;
 result = max(.,.); put 'max(.,.) is ' result;


max(1,.) is 1
max(.,.) is .

This is as expected. Now do the same thing without a DATA step, using %SYSFUNC:

 %put max(1,.) is %sysfunc(max(1,.));
 %put max(.,.) is %sysfunc(max(.,.));

The first statement passes a non-missing value to MAX, so the result is non-missing and the output is as above. In the second statement, both arguments are missing and MAX returns a missing value, causing %SYSFUNC to blow up:

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.
max(.,.) is .

This problem appears to be fixed in Version 9.2.