I'm trying to write a following function that I would like to minimize using a sas optlso. But I'm having difficulty in figuring out the logic. Any help in creating the logic would be very helpful.
here is the function:
The part that I cannot figure out is i ne j ne k ne i. If you can modify the below code to reflecy te a
Below is a reproducible example. Any help would be greating appreciated.
proc fcmp outlib=sasuser.myfuncs.mypkg;
function fdef1(x1, x2,x3,x4,x5,x6,x7);
array x[7];
array y[7,7] /nosym ( 1.0000 4.0000 9.0000 6.0000 6.0000 5.0000 5.0000
0.2500 1.0000 7.0000 5.0000 5.0000 3.0000 4.0000
0.1111 0.1429 1.0000 0.2000 0.2000 0.1429 0.2000
0.1667 0.2000 5.0000 1.0000 1.0000 0.3333 0.3333
0.1667 0.2000 5.0000 1.0000 1.0000 0.3333 0.3333
0.2000 0.3333 7.0000 3.0000 3.0000 1.0000 2.0000
0.2000 0.2500 5.0000 3.0000 3.0000 0.5000 1.0000);
fx = 0;
do i= 1 to dim(y);
do j = i+1 to dim(y);
do k = 1 to dim(y);
fx = fx + ((y[i,k]*y[k,j])-(x[i]/x[j]))**2;
end;
end;
end;
return(fx);
endsub;
run;
One additional question: Is there a way to print out the indices i j and k in the loop to a SAS log/dataset to QC ?
... View more