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 I have an error that I am trying to fix. 

 

proc optmodel;
set <str> Ports;
set <str> DC;
read data STDOPT.PN3381_Ports into Ports=[PortSource];
read data STDOPT.PN3381_DC into DC=[RateMatchDest];
num Containers {Ports,DC};
read data STDOPT.PN3381_data into [PortSource RateMatchDest] Containers=FEU;

Here is an instance of my error. But there are many more instances like this.

 The array element 'Containers[HPH,ADM]' has no value at line 125 column 71.

 

In my data, I know for a fact that there is no HPH,ADM. So, that combo HPH-ADM can be 0. But is SAS expect a value there of 0? 

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

The simplest change is:

num Containers {Ports,DC} init 0;

But the more efficient approach, to create a sparse index set of tuples, is what Natalia is suggesting:

set <str,str> Ports_DC;
num Containers {Ports_DC};
read data STDOPT.PN3381_data into Ports_DC=[PortSource RateMatchDest] Containers=FEU;

Then use Ports_DC in the rest of your code when you need to reference Containers.

View solution in original post

6 REPLIES 6
PinkOptimizer
SAS Employee
Without looking at the data I would guess it is because not all combinations of Ports and DCs exist in PN_3381_data.

I would suggest to read into a tuple set instead of individual PORTS and DCs, unless you need those even if they have no entry in PN_3381_data.

Do you need a sample syntax for the tuple set?

Cheers,
Natalia
Santha
Pyrite | Level 9

Hi Natalia

Yes you are right that it is because not all combinations of Ports and DCs exist in PN_3381_data.

And so i 

PortSource = "BOM'

RateMatchDest='ADM' 

FEU=100

so [BOM,ADU]=100 is a sample but [BOM,ADM] is not there in the data set. If it is not there in the data, its okay to ignore that combination which does not exist in the data in the first place. Does this answer ur question?

Santha
Pyrite | Level 9

Hi Natalia

Based on your response, I was able to artificially have 0 values in the data to avoid this problem.  However, I am not sure if this is a good approach. I am thinking probably not. If there is a way where we can tell ignore missing values in error that would be better.

Thank you

 

RobPratt
SAS Super FREQ

The simplest change is:

num Containers {Ports,DC} init 0;

But the more efficient approach, to create a sparse index set of tuples, is what Natalia is suggesting:

set <str,str> Ports_DC;
num Containers {Ports_DC};
read data STDOPT.PN3381_data into Ports_DC=[PortSource RateMatchDest] Containers=FEU;

Then use Ports_DC in the rest of your code when you need to reference Containers.

Santha
Pyrite | Level 9

THanks Rob and Natalia for your inputs . you guys are awesome

RobPratt
SAS Super FREQ

Glad to help.  You might also review this documentation example: SAS Help Center: Sparse Modeling

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 790 views
  • 1 like
  • 3 in conversation