First of all, use the {i} icon to post log snippets. Otherwise the white space in the logs is lost and with it the positioning of the ERROR messages (which point to the exact location in the code).
Second, don't post single log lines. ERRORs must be seen in context, so post the log of the complete step.
OK, so I've progressed but now it's giving me a submission error.
The full details are:
{} [TRACEBACK] at Object.<anonymous> (https://odamid.oda.sas.com/SASStudio/resources/js/webdms/DMSEditor.js:221:166) at Object.error (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:146:271) at https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:159:394 at c (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:221) at d (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:10) at b.Deferred.reject.errback (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:68:1) at c (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:493) at d (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:10)
Now, the program that I wrote that gives me this error (and many others when I run it) is:
proc optmodel; /* specify parameters */ set Fact={"Fact1","Fact2","Fact3","Fact4","Fact5"}; set Store={"Stor1","Stor2","Stor3","Stor4","Stor5"}; number CostPerKmPerProduct{Fact,Store}=[ 1 2517 1761 4053 2065 2517 1 1708 1663 711 1761 1708 1 2443 1316 4053 1663 2443 1 2251 2065 711 1316 2251 1 ]; number Demand{Store}=[ 3241 1127 1817 11023 15860 ]; number FixedCost{Fact}=[ 100000 100000 100000 100000 100000 ]; number M = 100000; /* model description */ var X{Fact,Store} integer >= 0; var Y{Fact} binary; min z = sum{i in Fact}sum{j in Store}X[i,j]*CostPerKmPerProduct[i,j] + sum{i in Fact}FixedCost[i]*Y[i]; con MinDemand{j in Store}: sum{i in DC}X[i,j] = Demand[j]; con Linking{i in Fact, j in Store}: X[i,j]-M*Y[i]<=0; con MinFact: sum{i in Fact}Y[i]=>4; con MaxFact: sum{i in Fact}Y[i]<=5; /* output and solve */ solve; print z X{Fact,Store} Y{Fact}; quit;
Thanks for your help!
If "the program that I wrote that gives me this error (and many others when I run it) is:"
then show the entire log for that step. The error messages will likely have many clues. Again post the log to include the code and any errors, warning or notes in a code box.
I note that the line with the error message in the original post does not occur in the example Proc Optmodel code.
your optmodel code does not run.
1. In your mindemand constraint you are summing over i in DC, where DC is not a defined set.
2. The greater or equal to sign in the MinFact constraint should be >=
3. In your print statement you should not have the index specification on your variables. Just write print z X Y
I am still getting the error preventing me from running the procedure (first error in my second post, with the screenshot). I attach below the corrected code I am using:
proc optmodel; /* specify parameters */ set Fact={"Fact1","Fact2","Fact3","Fact4","Fact5"}; set Store={"Stor1","Stor2","Stor3","Stor4","Stor5"}; number CostPerKmPerProduct{Fact,Store}=[ 1 2517 1761 4053 2065 2517 1 1708 1663 711 1761 1708 1 2443 1316 4053 1663 2443 1 2251 2065 711 1316 2251 1 ]; number Demand{Store}=[ 3241 1127 1817 11023 15860 ]; number FixedCost{Fact}=[ 100000 100000 100000 100000 100000 ]; number M = 100000; /* model description */ var X{Fact,Store} integer >= 0; var Y{Fact} binary; min z = sum{i in Fact}sum{j in Store}X[i,j]*CostPerKmPerProduct[i,j] + sum{i in Fact}FixedCost[i]*Y[i]; con MinDemand{j in Store}: sum{i in Fact}X[i,j] = Demand[j]; con Linking{i in Fact, j in Store}: X[i,j]-M*Y[i]<=0; con MinFact: sum{i in Fact}Y[i]>=4; con MaxFact: sum{i in Fact}Y[i]<=5; /* output and solve */ solve; print z X Y; quit;
Your optmodel code is fine. And it also works on my side in SAS Studio, so I would assume it is a configuration issue on your side that has nothing to do with the model. I am sorry, but that is outside my area of expertise
You might try the SAS Studio community: https://communities.sas.com/t5/SAS-Studio/bd-p/sas_studio
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.