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?
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.
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?
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
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.
THanks Rob and Natalia for your inputs . you guys are awesome
Glad to help. You might also review this documentation example: SAS Help Center: Sparse Modeling
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.