BookmarkSubscribeRSS Feed
YH
Calcite | Level 5 YH
Calcite | Level 5

Hi Everyone, 

 

I followed SAS OR example and made some modification as following. However, there are some error message I have no idea how to sole. Could you give me some suggestions? Thank you!

 

 

The error message of the following code are:

 

read data transport_cost_data into [o_city]
_
771
NOTE 771-782: The name 'o_city' hides an outer declaration.
55 {d_city in D_CITY} <transport_cost[o_city,d_city] = col(d_city)>;
______
771
NOTE 771-782: The name 'd_city' hides an outer declaration.

 

data demand_data;
input d_city $ Demand;
datalines;
Boston 150
New_York 150
;

data supply_data;
input o_city $ Supply;
datalines;
Detroit 200
Pittsburgh 100
;

data transport_cost_data;
input o_city $ Boston New_York;
datalines;
Detroit 30 20
Pittsburgh 40 10
;

 

proc optmodel;

/* specify parameters */
set <str> O_CITY;
num Supply {O_CITY};
read data supply_data into O_CITY = [o_city] Supply;

print Supply;

set <str> D_CITY;
num Demand {D_CITY};
read data demand_data into D_CITY = [d_city] Demand;

print Demand;

num transport_cost {O_CITY, D_CITY};
read data transport_cost_data into [o_city]
{d_city in D_CITY} <transport_cost[o_city,d_city] = col(d_city)>;

/* model description */
var x{O_CITY,D_CITY} >= 0;
min total_cost = sum{i in O_CITY, j in D_CITY}transport_cost[i,j]*x[i,j];
constraint supply_rule {i in O_CITY}: sum{j in D_CITY}x[i,j]=Supply[i];
constraint demand_rule {j in D_CITY}: sum{i in O_CITY}x[i,j]=Demand[j];

/* solve and output */
solve;
print x;

1 REPLY 1
RobPratt
SAS Super FREQ

These are only NOTEs and not ERRORs.  They arise because you are using o_city as a dummy index and O_CITY as a declared parameter.  Same story with d_city and D_CITY.  Because PROC OPTMODEL is case-insensitive, these look the same.  You can avoid the NOTEs by renaming one of them.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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