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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

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