Language Reference
FEVAL Function
FEVAL (funcname, <argument1, …, argument14> ) ;
This function is supported only by the IML procedure.
The FEVAL function enables you to evaluate a function indirectly. You specify the name of the function and its arguments. The FEVAL function returns the result of calling the function with the specified arguments.
The arguments to the FEVAL function are as follows:
- funcname
specifies the name of an existing built-in function or user-defined function. You can specify the function name as a literal string or as a matrix that contains the function name.
- argument
specifies an argument that is passed to the function. You can specify up to 14 arguments. These arguments can be of any dimension and any type (character, numeric, lists, and so on).
For example, the following program uses the FEVAL function to evaluate the MEAN function on a column vector of data:
y = {0,1,2,4,4,5,6,6,17};
m = FEval("mean", y); /* same as MEAN(y) */
For this example, calling the FEVAL function offers little advantage over calling the MEAN function directly. However, the next example uses a DO loop to evaluate six different functions that compute descriptive statistics. The names of the functions are contained in a character vector. Each function has the syntax funcname(y). The six descriptive statistics are shown in Figure 156.
stats = {"mean" "median" "std" "var" "skewness" "kurtosis"};
results = j(1, ncol(stats), .);
do i = 1 to ncol(stats);
results[i] = FEval(stats[i], y);
end;
print results[colname=stats format=best5.];
Figure 156: Descriptive Statistics from Calling Six Functions
| results | |||||
|---|---|---|---|---|---|
| mean | median | std | var | skewness | kurtosis |
| 5 | 4 | 4.975 | 24.75 | 1.974 | 4.918 |