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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

Sorry, try this instead:

   print {p in Ports, c in IC} (InboundLinehaul [p,c] * sum {d in DC} ContainersfromPortstoICtoDC [p,c,d]);

View solution in original post

10 REPLIES 10
RobPratt
SAS Super FREQ

Does this do what you want?

   print {p in Ports, c in IC} (sum {d in DC} Inbound_Linehaul_Costs[p,c,d]);
Santha
Pyrite | Level 9

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

RobPratt
SAS Super FREQ

Sorry, try this instead:

   print {p in Ports, c in IC} (InboundLinehaul [p,c] * sum {d in DC} ContainersfromPortstoICtoDC [p,c,d]);
Santha
Pyrite | Level 9

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

RobPratt
SAS Super FREQ

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;
Santha
Pyrite | Level 9

Ok. Let me try these and let you know. Thanks a lot

Santha
Pyrite | Level 9

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 

RobPratt
SAS Super FREQ

Glad to help.

Santha
Pyrite | Level 9

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]);

RobPratt
SAS Super FREQ

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;

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 10 replies
  • 1036 views
  • 1 like
  • 2 in conversation