BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
brunomsl
Calcite | Level 5

Hi everyone,

 

I have a distribution problem, that I'm trying to save the results in a new data set. The problem is very similar to the SAS/OR  14.3 user's guide documentation  example (which i pasted below):

data arc_data;
input j $11. i $11. cost;
datalines;
Newcastle Liverpool 0.5
Birmingham Liverpool 0.5
Birmingham Brighton 0.3
London Liverpool 1.0
London Brighton 0.5
Exeter Liverpool 0.2
Exeter Brighton 0.2
C1 Liverpool 1.0
C1 Brighton 2.0
C1 Birmingham 1.0
C2 Newcastle 1.5
C2 Birmingham 0.5
C2 London 1.5
C3 Liverpool 1.5
C3 Newcastle 0.5
C3 Birmingham 0.5
C3 London 2.0
C3 Exeter 0.2
C4 Liverpool 2.0
C4 Newcastle 1.5
C4 Birmingham 1.0
C4 Exeter 1.5
C5 Birmingham 0.5
C5 London 0.5
C5 Exeter 0.5
C6 Liverpool 1.0
C6 Newcastle 1.0
C6 London 1.5
C6 Exeter 1.5
;
data customer_data;
input customer $ demand;
datalines;
C1 50000
C2 10000
C3 40000
C4 35000
C5 60000
C6 20000
;
data factory_data;
input factory $10. capacity;
datalines;
Liverpool 150000
Brighton 200000
;
data depot_data;
input depot $11. throughput;
datalines;
Newcastle 70000
Birmingham 50000
London 100000
Exeter 40000
;
data preferred_arc_data;
input j $ i $11.;
datalines;
C1 Liverpool
C2 Newcastle
C5 Birmingham
C6 Exeter
C6 London
;

proc optmodel;
set <str,str> ARCS;
num cost {ARCS};
read data arc_data into ARCS = [i j] cost; 
set <str> FACTORIES; 
num capacity {FACTORIES}; 
read data factory_data into FACTORIES=[factory] capacity;
set <str> DEPOTS; 
num throughput {DEPOTS};
read data depot_data into DEPOTS=[depot] throughput; 
set <str> CUSTOMERS; 
num demand {CUSTOMERS};
read data customer_data into CUSTOMERS=[customer] demand;
set NODES = FACTORIES union DEPOTS union CUSTOMERS; 
num supply {NODES} init 0; 
for {i in FACTORIES} supply[i] = capacity[i]; 
for {i in CUSTOMERS} supply[i] = -demand[i]; 
var Flow {ARCS} >= 0; 
con Flow_balance_con {i in NODES}: 
sum {<(i),j> in ARCS} Flow[i,j] - sum {<j,(i)> in ARCS} Flow[j,i] <= supply[i]; 
con Depot_con {i in DEPOTS}: 
sum {<(i),j> in ARCS} Flow[i,j] <= throughput[i];
min TotalCost = sum {<i,j> in ARCS} cost[i,j] * Flow[i,j]; 
solve;
print {<i,j> in ARCS: Flow[i,j].sol > 0} Flow; 
quit;

I'm trying to save the same result displayed by the code line:

print {<i,j> in ARCS: Flow[i,j].sol > 0} Flow; 

I tried to add the line:

 

create data results from col({<i,j> in ARCS: Flow[i,j].sol > 0} Flow) = i j flow ;

But I get this error:

 

22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, .., /, <, <=, <>, =, >, ><, >=, AND, BY, CROSS,
DIFF, ELSE, IN, INTER, OR, SYMDIFF, TO, UNION, WITHIN, ^, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

 

Can anyone help? 

 

Thanks;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ
create data results from [i j]={<i,j> in ARCS: Flow[i,j].sol > 0} Flow;

View solution in original post

2 REPLIES 2
RobPratt
SAS Super FREQ
create data results from [i j]={<i,j> in ARCS: Flow[i,j].sol > 0} Flow;
brunomsl
Calcite | Level 5

Thank you!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Discussion stats
  • 2 replies
  • 1390 views
  • 1 like
  • 2 in conversation