Hi Rob
This is from https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565617/...
I am trying to see the results my various cost buckets. For example, if i want to see my Inbound_Linehaul_Costs (that is an implicit variable in the model) by different lanes (lanes are Ports-IC combinations), how do i do that? Can you help me with that. My model succesfully solved. I just dont know how to extract the relevant outputs.
Sorry, try this instead:
print {p in Ports, c in IC} (InboundLinehaul [p,c] * sum {d in DC} ContainersfromPortstoICtoDC [p,c,d]);
Does this do what you want?
print {p in Ports, c in IC} (sum {d in DC} Inbound_Linehaul_Costs[p,c,d]);
HI rob
I tried that. I got an error that said:
ERROR 616-782: The name 'Inbound_Linehaul_Costs' must be an array.
Inbound_Linehaul_Costs is an impvar in my model
Sorry, try this instead:
print {p in Ports, c in IC} (InboundLinehaul [p,c] * sum {d in DC} ContainersfromPortstoICtoDC [p,c,d]);
HI Rob.
Thank you ,. That worked like a charm. But a question I have, so we have to do the formula of Number of containers * Costs again . Right?
Also, how do I create a dataset of this printstatement you mentioned. Because if we can do that, I can probably download that into xls or whatever format is convenient for the end user. Thank you
Here's one way:
create data outdata from [p c]={p in Ports, c in IC}
Inbound_Linehaul_Costs_p_c=(InboundLinehaul[p,c] * sum {d in DC} ContainersfromPortstoICtoDC[p,c,d]);
Alternatively, you can declare another IMPVAR so that the formula appears in only one place:
impvar Inbound_Linehaul_Costs_p_c {p in Ports, c in IC}
= InboundLinehaul[p,c] * sum {d in DC} ContainersfromPortstoICtoDC[p,c,d];
impvar Inbound_Linehaul_Costs
= sum {p in Ports, c in IC} Inbound_Linehaul_Costs_p_c[p,c];
create data outdata from [p c] Inbound_Linehaul_Costs_p_c;
Ok. Let me try these and let you know. Thanks a lot
Awesome. That worked. Your guidance had greatly helped me from start to finish for my first sas model. Eager to learn more in future.
Thanks for your time and effort
Glad to help.
If i want to restrict to only those where the costs >0 ,how do i specify that?
create data outdata from [p c]={p in Ports, c in IC} Inbound_Linehaul_Costs_p_c=(InboundLinehaul[p,c] * sum {d in DC} ContainersfromPortstoICtoDC[p,c,d]);
One way is to use a WHERE= data set option in the CREATE DATA statement:
create data outdata(where=(Inbound_Linehaul_Costs_p_c > 0)) from [p c]={p in Ports, c in IC}
Inbound_Linehaul_Costs_p_c=(InboundLinehaul[p,c] * sum {d in DC} ContainersfromPortstoICtoDC[p,c,d]);
If you instead declared Inbound_LInehaul_Costs_p_c as an IMPVAR, you can also accomplish this by using a logical condition in the index set:
create data outdata from [p c]={p in Ports, c in IC: Inbound_Linehaul_Costs_p_c[p,c] > 0}
Inbound_Linehaul_Costs_p_c;
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 16. Read more here about why you should contribute and what is in it for you!
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.