0 0
Read Time:7 Minute, 46 Second

Transportation Problem

Step 1: Write proc optmodel;

proc optmodel;

That was easy.

Step 2: Create all your “assets”.

I call them assets, but you can call them whatever you want. Think of them as anything in the problem that we can assign attributes to. In this case, we have the Plants and the Regions. So we will create two sets, one for each. That’s why we use the command “set”.

set Plant={“Plant 1″,”Plant 2”};

set Region={“Region 1″,”Region 2”, “Region 3”};

I like calling things by their name, so I can remember them. Make sure to use {} for the sets, and to put each name inside quotes.

Step 3: Input all your data

This is all the information that in being shared in the problem. They will generally be attributes for each of the assets, or they can be constants. For all of these we use the command number:

number demand{Region} = [25 95 80];

number capacity{Plant} = [100 125];

number cost{Plant, Region} = [

250 325 445

275 260 460


The general nomenclature is that you give a name to the attribute, put what asset it describes inside {} and then put the values inside []. When writing tables in, make sure to write {rows,columns}. In the case of the cost, the plants would be the rows, and the regions would be the columns. Make sure that the order of the numbers you input matches the order of the items you defined in your set; SAS will assign the first number to the first item in the set, and so on. It also helps to space out tables to better read them and catch mistakes.

Step 4: Establish your variables

In this case, variables are the flows from the Plants to the Regions.

var flow{Plant, Region} >= 0;

Putting Plant,Region inside the {} means we will have a flow for each combination of Plant and Region. This means six variables will be created flow(Plant 1, Region 1), flow(Plant 1, Region 2), flow(Plant 1, Region 3), flow (Plant 2, Region 1), flow(Plant 2, Region 2), and flow(Plant 2, Region 3). Always remember to define what type of variable it is. In this case, we want our variables to be non-negative.

Step 5: Define your objective function

I called it z here, but you can call it anything you want, like TotalCost if you want to be more descriptive

minimize z = sum{i in Plant, j in Region}flow[i,j]*cost[i,j];

When you write sum {i in Plant, j in Region }, it’s the equivalent of doing a sumproduct in Excel. SAS will take every combination of Plant and Region and do the described calculation of flow times cost, and then add them all up. So in this case, it would take flow[Plant 1, Region 1]*cost[Plant 1, Region 1], then flow[Plant 1, Region 2]*cost[Plant 1, Region 2], do that for all the combinations, and then compute the sum.

I could’ve used p instead of i, and r intead of j, like sum {p in Plant, r in Region}flow[p,r]*cost[p,r]), or any other letter for that matter as long as I remain consistent and I haven’t used that letter to describe something else already.

Step 6: Establish your Constraints

In this case there are only two general contraints: capacity contraints for the plants, and demand constraints for the regions:

con capacitycon{i in Plant}: sum{j in Region}flow[i,j] <= capacity[i];

con demandcon{j in Region}: sum{i in Plant}flow[i,j] >= demand[j];

Let’s take as an example the first constraint. On the left side of the :, con capacitycon{i in Plant}, establishes the name of the constraint as capacitycon. The {I in Plant} means this is a constraint that applies individually to every Plant, so the constraint will be calculated individually for every item in the set Plant. This means this constraint really works as two constraints in this case, one using values for Plant 1, and another using values for Plant 2.

After the “:” we define the constraint itself. Here, SAS will take the flow and change the value j using every  region, and add them up, and it will compare that to the capacity of the Plant. Since we established before the “:” that the constraint would be calculated separately for each Plant, the Plant remains constant for each iteration of the constraint calculation. In essence, it would take the flow(P1, R1) + flow(P1, R2) + flow(P1,R3) and make sure that is less that or equal to the capacity of (P1). Again notice that the Plant doesn’t change; instead, the constraint will do the calculations for Plant 2 as a separate comparison, because we established the {i in Plant} on the left of the “:”.

Step 7: Wrap it up

solve; print z flow; expand; quit;

Don’t forget to check the log for any error (the middle tab between you code and the results). SAS will highlight any mistakes you would’ve made there. Just scroll up to see where the first red line of text is, and that was your first mistake. You can follow these steps any time you are using SAS with this notation.

Transhipment Problem

Network Facility Location Problem

    “transcost” was not used in the sas files, as it is not required when the transportation cost is $1. If it is any other value, will need to add that in.

Network Facility Location Problem w/ LOS

    copy and paste matrix from spreadsheet…

to calculate the binary table dynamically, see below from page  12


For the demand constraint “demandcon“, use an equality instead of inequality as otherwise the solution will create non-integer demand, just to meet the LOS constraint. 

Advanced Supply Chain Network Design

    Supply Chain Network Design Problem

Multi-Commidity Flow Problem:

    Data tables come before “proc optmodel;”


 INFILE Statement Options

DELIMITER= option—Specifies what character (other than the blank default character) to         use as the delimiter in files that are being read. Common delimiters include comma (,), vertical pipe (|), semi-colon (;) , and the tab. For example, to specify a vertical pipe as the delimiter, the syntax is DLM=’|’, as shown here: infile ‘C:\mydata\test.dat’ dsd dlm=’|’ lrecl=1024;

A tab is specified by its hexadecimal value. For ASCII systems (UNIX, Windows, and Linux), the value is ’09’x. For EBCDIC systems (z/OS and MVS), the value is ‘05’x. As an example, the syntax to specify a tab delimiter on an ASCII system is DLM=’09’x. Note: The positioning of the quotation marks and the x in hexadecimal values is critical. No space is allowed between the x and the quotation marks, as shown in this example: infile ‘C:\mydata\test.txt’ dsd dlm=’09’x truncover;

In my case I have troubles with the ASCII so I used dlm=’,’; and I separated the data with , and it run.    

Reading Delimited Text Files.pdf

/* 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;


P1 Chicago Atlanta 6

P1 Chicago Boston 5

P1 Dallas Atlanta 4

P1 Dallas Boston 7

P1 Miami Atlanta 6

P1 Miami Boston 9

P2 Chicago Atlanta 6

P2 Chicago Boston 5

P2 Dallas Atlanta 4

P2 Dallas Boston 7

P2 Miami Atlanta 6

P2 Miami Boston 9

P3 Chicago Atlanta 6

P3 Chicago Boston 5

P3 Dallas Atlanta 4

P3 Dallas Boston 7

P3 Miami Atlanta 4

P3 Miami Boston 7



/* Inputing values of multi-dimensional matrix outcost in a table form first*/

Data outcost;

infile datalines dsd delimiter=’09’x;

input Product $ DC $ Region $ outcost;


P1 Atlanta NY 8

P1 Atlanta VA 5

P1 Atlanta PA 6

P1 Boston NY 9

P1 Boston VA 7

P1 Boston PA 6

P2 Atlanta NY 7

P2 Atlanta VA 8

P2 Atlanta PA 5

P2 Boston NY 3

P2 Boston VA 8

P2 Boston PA 6

P3 Atlanta NY 7

P3 Atlanta VA 4

P3 Atlanta PA 4

P3 Boston NY 4

P3 Boston VA 5

P3 Boston PA 4



Fixed Planning Horizon Problem

Aggregate Planning And Distribution Channel Strategies

Aggregate Planning (including numerous factors like hiring and firing, production levels, etc)

Aggregate Planning with Demand Elasticity (including factors like hiring and firing, production levels, discounts, etc)

Omni-channel Network Design

Reverse Logistics…for Batteries

Optimization Based Procurement

Simple Auctions

Capacity by Lane Constraint

Level of Service Constraint

Supplier Capacity Constraint

Minimum $$ Volume Constraint

Combinatorial Bids

Combinatorial Bids (Min 2 carriers) – Add the following constraint to the previous model.

SAS Files



0 %
0 %
0 %
0 %
0 %
0 %