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

Hello,

 

Please, can anyone help me with my code? I am getting always "semantic error". 

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
7 REPLIES 7
Kurt_Bremser
Super User

Do not use Office Files for posting code. Those files are often used to transport malware and are therefore blocked by many, if not most, corporate firewalls.

The proper way to post SAS code is the "little running man" icon. It preserves formatting and gives a look similar to the SAS Enhanced Editor.

For logs and non-SAS code, use the {i} icon.

jfm00
Fluorite | Level 6

Hi,

When I run this code, I get errors. Can anyone help me correct my code? Thanks

 

In this problem, I have fixed costs per plant and per product and also minimum and maximum production per plant and per product.

 

 

 

Proc optmodel;
set Plant = {'P1','P2','P3','P4','P5'};
set Product = {'T1','T2','T3','T4'};

number Supply {Plant} = [615 635 650 573 634] ;
number Demand {Product} = [510 450 458 521];
number VariaCost {Plant,Product} = [
22.45 24.05 23.2 25
21.85 24.35 24.25 24.8
25.15 24.9 25.45 24.2
25       25.75  21.75 21.15
21.6 23.6 21.7 24.05];
number FixedCost {Plant,Product} = [
971     429    1138 1001
1188 845  485 1336
529      975    1227 1280
1325 1164 485   302
1297 979  536 769];
number M = 1000000;
number MinUse {Plant,Product} = [
146  53   125  147
105  104  125  122
141  53   128  50
69   132  89   57
95   84   108  116];
number MaxUse {Plant,Product} = [
283  346  328  306
356  366  278  336
371  373  347  355
282  340  346  332
334  332  295  348];

var X {Plant,Product} integer >= 0;
var Y {Plant} binary;

minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j] ) + Y[i]*FixedCost[i,j] );

con SupplyConst {i in Plant} : sum {j in Product} X[i,j]<=Supply[i];
con DemandConst {j in Product} : sum {i in Plant} X[i,j]>=Demand[j];
con Producing {i in Plant} : sum {j in Product} X[i,j] <= M * Y[i];
con UseMinimum {i in Plant} : sum {j in Product} (sum {i in Plant}) X[i,j] >= MinUse[i,j] * Y[i];
con UseMaximum {i in Plant} : sum {j in Product} (sum {i in Plant}) X[i,j] <= MaxUse[i,j];


solve;

print TotalCost X;

quit;

Kurt_Bremser
Super User

When you need help with a SAS error, post the log (of the whole step!). And as I already stated(!), use the proper icons for posting code and log.

If the ERROR could be caused by the data, post example data in a data step as described here.

RobPratt
SAS Super FREQ

See this related post from December.

Ksharp
Super User

Plz post it at OR forum. @RobPratt is there.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 1037 views
  • 2 likes
  • 4 in conversation