I am using SAS proc IML to solve the nonlinear equation (x-0.11)(x-0.32)(x-0.98) = 0. I have to provide initial values for the proc IML. I would like to use 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 as initial values. The SAS program for initial value 0.1 is below. Now I have to repeat the SAS program below for each of the initial values. I am wondering if there is an elegant way to do it.
proc iml;
start Fun(var);
x = var[1];
f = j(1, 1, .); /* return a ROW VECTOR */
f[1] = (x-0.11)*(x-0.32)*(x-0.98);
return (f);
finish;
/* x constraints. Lower bounds in 1st row; upper bounds in 2nd row */
con = {1e-6, /* x > 0*/
. };
x0 = {0.1}; /* initial guess */
optn = {1 /* solve least square problem that has 1 components */
1}; /* amount of printing */
call nlphqn(rc, Soln, "Fun", x0, optn) blc=con; /* or use NLPLM */
print Soln;
create root var {Soln}; /** create data set **/
append; /** write data in vectors **/
close root; /** close the data set **/
quit;