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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.