Most functions that can be invoked from the DATA step or the %SYSFUNC macro can be used in PROC OPTMODEL expressions. Certain functions are specific to the DATA step and cannot be used in PROC OPTMODEL. Functions specific to the DATA step include these:
functions in the LAG, DIF, and DIM families
functions that access the DATA step program data vector
functions that access symbol attributes
The CALL statement can invoke SAS library subroutines. These subroutines can read and update the values of the parameters and variables that are used as arguments. See the section CALL Statement for an example.
OPTMODEL arrays can be passed to SAS library functions and subroutines using the argument syntax:
OF array-name[*] . suffix
The array-name is the name of an array symbol. The optional suffix allows auxiliary values to be referenced, as described in section Suffixes.
The OF argument form is resolved into a sequence of arguments, one for each index in the array. The array elements appear in order of the array’s index set. The OF array form is a compact alternative to listing the array elements explicitly.
As an example, the following statements use the CALL SORTN function to sort the elements of a numeric array:
proc optmodel; number original{i in 1..8} = sin(i); number sorted{i in 1..8} init original[i]; call sortn(of sorted[*]); print original sorted;
The output is shown in Figure 5.33. Eight arguments are passed to the SORTN routine. The original
column shows the original order, and the sorted
column has the sorted order.