my code is not working. It is showing an error of unknown c1, c2, c3, c4, and so unknown f. Please help me out. Thanks
data x (drop = i);
do i = 1 to 100;
c1 = ranuni(i);
c2 = ranuni(i);
c3 = ranuni(i);
c4 = ranuni(i);
output;
end;
run;
proc print data = x;var c1 c2 c3 c4;run;
proc optmodel;
var a;
var b;
%do i = 1 %to dim(x)
minimize f =(((1-((c1[i]*a+c2[i]*b)/30.9))**2)*1.08)+(((1-((c3[i]*a+c4[i]*b)/12.8))**2)*1);
con P: a+b=1.0;
con Q: a >= 0.0;
con R: b >= 0.0;
con T: a <= 1.0;
con U: b <=1.0;
solve with qp;
/* print the optimal solution */
print a b;
print f;
quit;
end;
var b;
%do i = 1 %to dim(x)
minimize f =(((1-((c1[i]*a+c2[i]*b)/30.9))**2)*1.08)+(((1-((c3[i]*a+c4[i]*b)/12.8))**2)*1);
con P: a+b=1.0;
con Q: a >= 0.0;
con R: b >= 0.0;
con T: a <= 1.0;
con U: b <=1.0;
solve with qp;
/* print the optimal solution */
print a b;
print f;
quit;
end;
The syntax you've written is not valid for several reasons, all having to do with the macro processing.
Please describe in words what you are trying to accomplish so we can advise the best way to do it.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!