Hi I'm running PROC OPTMODEL with internal data and data thr' read data X into X but after long struggle I'm not able to as SAS is not throwing any error and according to me logic is same for both the methods. I'm pasting both code with and without read data into plz let me know where i'm making error data thr read data into (This does not works): Data Products;
input Product $ Demand Ethiopia Tanzania Nigeria;
datalines;
Ginko 550 21.00 22.50 23.00
Kola 450 22.50 24.50 25.50
;
data Locations;
input Location $ Capacity;
datalines;
Ethiopia 425
Tanzania 400
Nigeria 750
;
PROC OPTMODEL ;
SET <string> Locations;
SET <string> Products;
number cost{Products, Locations};
number Capacity{Locations};
number Demand{Products};
var Amount{Products, Locations} >= 0;
minimize ProdCost = sum { i in Products} sum {j in Locations} Amount[i,j]*cost[i,j];
con PlantCapacity {j in Locations} : sum{i in Products}Amount[i,j] <= Capacity[j];
con ProductDemand {i in Products} : sum{j in Locations}Amount[i,j] >= Demand[i];
read data Locations into Locations=[Location] Capacity=Capacity;
read data Products into Products=[Product] Demand = Demand
{j in Locations} < cost[Product, j] = col(j) >;
print ProdCost;
print Amount;
print cost;
print Capacity;
print Demand;
QUIT; data internally read (But this Works): proc optmodel;
set Products = {"Ginko","Kola"};
set Locations= {"Ethiopia", "Tanzania", "Nigeria"};
number Costs{Products, Locations} = [
21.00 22.50 23.00
22.50 24.50 25.50 ];
number Capacity{Locations} = [425 400 750];
number Demand{Products} = [550 450];
var Amount{Products, Locations} >= 0;
minimize z = sum{i in Products}sum{j in Locations}Costs[i, j]*Amount[i,j];
con CapacityC{j in Locations}: sum{i in Products}Amount[i,j] <= Capacity[j];
con DemandC{i in Products}: sum{j in Locations}Amount[i,j] >= Demand[i];
solve;
print Amount z;
quit;
... View more