hello, I've been trying to resolve the next linear programming problem...but, what I only got is an error:
OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
Are you using SAS UE? If so, I don't think proc optmodel is included.
It falls under SAS/OR which is not part of SAS UE.
Yes I do
If you are using SAS University Edition, then you have access to SAS/IML, which supports linear programming (LP) and mixed-integer LP. . Use the MILPSOLVE subroutine, as follows
/* Problem: x is a vector of integers 0 <= x[i] <= 10
maximize c*x = 3*x1 + 5*x2
subject to
A*x SYMBOL b
where SYMBOL is a vector of symbols that indicate <=, =, or >=
*/
proc optmodel;
var x{i in 1..2} integer >= 0;
max z = 3*x[1] + 5*x[2];
con c1: 3*x[1] + -2*x[2] <= 10;
con c2: 5*x[1] + 10*x[2] <= 56;
solve with milp;
print x;
quit;
proc iml;
/* information about variables (row of column, doesn't matter) */
colType = {I, I}; /* variables are integers */
LowerB = {0, 0}; /* lower bound contraints on x */
UpperB = {10,10}; /* upper bound contraints on x */
/* objective function */
c = {3 5}; /* vector for objective function c*x */
/* linear constraints */
A = {3 -2, /* matrix of contraint coefficients */
5 10};
b = {10, /* RHS of constraint eqns (column vector) */
56};
/* specify symbols for constraints:
'L' for less than or equal
'E' for equal
'G' for greater than or equal */
LEG = {L, L};
/* control vector for optimization */
ctrl = {-1, /* maximize objective */
1}; /* print level */
CALL MILPSOLVE(rc, objVal, result, relgap, /* output variables */
c, A, b, /* objective and linear constraints */
ctrl, /* control vector */
coltype, LEG, /*range*/, LowerB, UpperB);
print rc objVal relgap, result[rowname={x1 x2}];
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.