BookmarkSubscribeRSS Feed
Ibraheem123
Calcite | Level 5

I don't know where  is the problem  ?

this is my code 

/* Inputing values of multi-dimensional matrix incost in a table form first*/
Data incost;
infile datalines dsd delimiter='09'x;
input Product $ Plant $ DC $ incost;
datalines;
P1 Barranqu Bogotá 130
P1 Barranqu Medellín 90.6
P1 Barranqu Cali 142
P1 Santander Bogotá 53.6
P1 Santander Medellín 41.6
P1 Santander Cali 88.8
P2 Barranqu Bogotá 130
P2 Barranqu Medellín 90.6
P2 Barranqu Cali 142
P2 Santander Bogotá 53.6
P2 Santander Medellín 41.6
P2 Santander Cali 88.8

;
Run;


proc optmodel;

set Product = {'P1','P2'};
set Plant = {'Barranqu','Santander'};
set DC = {'Bogotá','Medellín','Cali'};

 

number PlCapacity{Plant} = [610 350 ];

number incost{Product,Plant,DC};
Read data inCost into [Product Plant DC] inCost;


number Demand{Product,DC} = [
276 210.4 137.6
69 52.6 34.4

];

var inflow{Product,Plant,DC} >= 0;

/* Minimize Total Transport cost = Inbound transport cost + Outbound transport cost */
minimize Z=sum{l in Product,i in Plant,k in DC}(inflow[l,i,k]*incost[l,i,k]);
con PlantCon{i in Plant}: sum{l in Product,k in DC}(inflow[l,i,k])<=PlCapacity[i];
con DCCon{l in Product,k in DC}: sum{i in Plant}(inflow[l,i,k])>=Demand[l,k];

solve;
print z inflow ;
quit;

1 REPLY 1
Kurt_Bremser
Super User

Look at your incost dataset. Using just $ defines a variable with a length of 8, which is too short for your values ("Santander" has 9 characters, and the UTF characters in "Medellín" cause the actual data to be longer).

This data step will create a dataset where the rest of the code works:

data incost;
input Product $ Plant :$9. DC :$10. incost;
datalines;
P1 Barranqu Bogotá 130
P1 Barranqu Medellín 90.6
P1 Barranqu Cali 142
P1 Santander Bogotá 53.6
P1 Santander Medellín 41.6
P1 Santander Cali 88.8
P2 Barranqu Bogotá 130
P2 Barranqu Medellín 90.6
P2 Barranqu Cali 142
P2 Santander Bogotá 53.6
P2 Santander Medellín 41.6
P2 Santander Cali 88.8
;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 445 views
  • 0 likes
  • 2 in conversation