SAS Optimization, and SAS Simulation Studio

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-24-2017 10:09 AM

Hello everyone,

I am a beginner and I am trying to play around with OPTMODEL, but I am getting a few errors I can't decipher. Is there a reference guide to go through the error codes they give us?

I enclose two error examples below.

Thank you.

102 con MaxNumberFactory: sum{i in Factory}Y[i]=>2;

_

22

200

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,

a missing value, (, +, -, /, IF, INPUT, INTER, MAX, MIN, PROD, PUT, SETOF, SLICE, SUM, UNION, {.

ERROR 200-322: The symbol is not recognized and will be ignored.

107 print X{Factory,Store};

_

22

ERROR 22-322: Expecting a name.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to enjoylois0

04-24-2017 10:19 AM

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.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

Maxims of Maximally Efficient SAS Programmers

How to convert datasets to data steps

How to post code

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to KurtBremser

04-24-2017 10:31 AM

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!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to enjoylois0

04-24-2017 03:23 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

04-25-2017 03:54 AM

@ballardw:

I have put the whole error in the first code box, preceded by "the full details are".

This error doesn't allow me to run the procedure, so there is no log to share so far I'm afraid.

But I understand you manage to run the Proc Optmodel code? There must be an error with my SAS Studio software, then?

I have put the whole error in the first code box, preceded by "the full details are".

This error doesn't allow me to run the procedure, so there is no log to share so far I'm afraid.

But I understand you manage to run the Proc Optmodel code? There must be an error with my SAS Studio software, then?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to enjoylois0

04-25-2017 04:36 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to berlinnov

04-25-2017 06:15 AM

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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to enjoylois0

04-25-2017 07:10 AM - edited 04-25-2017 07:11 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to berlinnov

04-25-2017 07:37 AM

Can anybody advise as to where I could contact SAS to get help on this configuration issue?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to enjoylois0

04-25-2017 02:32 PM

You might try the SAS Studio community: https://communities.sas.com/t5/SAS-Studio/bd-p/sas_studio