READARRAY
SAS-data-set-1 <SAS-data-set-2
SAS-data-set-k> ;
PROC FCMP (see The FCMP Procedure) provides the READ_ARRAY function to read data from a SAS data set into array variables. In order to ensure that the referenced data sets are available, PROC OPTLSO also requires that the names of these data sets be provided as a list of names in the READARRAY statement. For an example, see the second program in Using External Data Sets. The following example creates and reads a SAS data set into an FCMP array variable:
data barddata; input y @@; datalines; 0.14 0.18 0.22 0.25 0.29 0.32 0.35 0.39 0.37 0.58 0.73 0.96 1.34 2.10 4.39 ; proc fcmp outlib=sasuser.myfuncs.mypkg; function bard(x1, x2, x3); array y[15] / nosym; rc = read_array('barddata', y); fx = 0; do k=1 to 15; dk = (16-k)*x2 + min(k,16-k)*x3; fxk = y[k] - (x1 + k/dk); fx = fx + fxk**2; end; return (0.5*fx); endsub; run; options cmplib = sasuser.myfuncs; data _null_; bval = bard(1,2,3); put bval=; run;
Here the call to READ_ARRAY in the PROC FCMP function definition of Bard
populates the array Y
with the rows of the BardData
data set. If the Bard
function were subsequently used in a problem definition for PROC OPTLSO, the BardData
data set should be listed in the corresponding READARRAY statement of PROC OPTLSO as demonstrated in the second program in
Using External Data Sets.