The OPTMODEL Procedure
Function Expressions
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 one of the following argument syntax forms:
The array-name is the name of an array symbol. The optional suffix allows auxiliary values to be referenced, as described in section Suffixes. You can also use an identifier-expression with a suffix that allows a solution index, specifying an asterisk (*) in place of the index expression.
The OF array form is a compact alternative to listing the array or solution elements explicitly. The OF argument form is resolved into a sequence of arguments, one for each index in the array or for each solution index. The array elements appear in order of the array’s index set. Solutions appear in solution index order. If you use an asterisk for both the array and solution index lists, an argument appears for each combination of array and solution indices, and the solutions for each array index are placed in contiguous arguments.
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 33. Eight arguments are passed to the SORTN routine. The original column shows the original order, and the sorted column has the sorted order.
Figure 33: Sorting Using an OF Array Argument
| [1] | original | sorted |
|---|---|---|
| 1 | 0.84147 | -0.95892 |
| 2 | 0.90930 | -0.75680 |
| 3 | 0.14112 | -0.27942 |
| 4 | -0.75680 | 0.14112 |
| 5 | -0.95892 | 0.65699 |
| 6 | -0.27942 | 0.84147 |
| 7 | 0.65699 | 0.90930 |
| 8 | 0.98936 | 0.98936 |