First, you need to realize that there is NO SUCH THING as a "local" or "nested" module. All modules are global in scope.
Second, you might want to review the rules for local and global symbols in a module.
Together, these rules imply that you can run the program like this:
proc iml;
Start SSE(alpha) global(g_x,g_y);
m = nrow(g_y);
res = j(1,m,0);
res = ((g_y - (alpha[1] + g_x*alpha[2:ncol(alpha)]))##2)`;
return(res);
finish SSE;
Start reg(x,y) global(g_x, g_y);
g_x = x; g_y = y; /* copy into global symbols */
alpha = {0.5 30};
m1 = nrow(y);
optn = m1||2;
con = {0 0,
. 1};
call NLPLM(rc,xres,"SSE",alpha,optn,con);
print rc;
print xres;
return(xres);
finish reg;
x = {1,1,1,2,2,2,3,3,3};
y = {0.5,0.6,0.5,1,1.2,1,1.5,1.5,1.6};
xres = reg(x,y);
m1 = nrow(y);
xd = (j(m1,1,1) || x);
sol = solve(xd`*xd,xd`*y); /*checking*/
print sol;
... View more