Hey,
I have a syntaxe problem with the following procedure, someone can help me? I think that it is with the objectif function.
Thank you,
data fooddata; infile datalines;
input name $ prod $ cost prot fat carb cal Moy; datalines;
Breadb B 2.5 4 1 15 90 150
Breadc C 2 4 1 15 90 212
Milkb B 4 8 5 11.7 120 0
Milkc C 3.5 8 5 11.7 120 350
Cheeseb B 12 7 9 0.4 106 20
Cheesec C 8 7 9 0.4 106 50
;
run;
proc optmodel; /* declare index set */ set<str> FOOD;
/* declare variables */ var diet{FOOD} >= 0;
/* objective function */
num Moy{FOOD}; num cost{FOOD}; min f=(sum{i in FOOD, j=2i-1}((Moy[j]+Moy[j+1])-(diet[j]+diet[j+1]))**2)+sum{i in FOOD}cost[i]*diet[i];
/* constraints */
num prot{FOOD}; num fat{FOOD}; num carb{FOOD}; num cal{FOOD};
num min_cal, max_prot, min_carb, min_fat; con cal_con: sum{i in FOOD}cal[i]*diet[i] >= 300;
con prot_con: sum{i in FOOD}prot[i]*diet[i] <= 10; con carb_con: sum{i in FOOD}carb[i]*diet[i] >= 10;
con fat_con: sum{i in FOOD}fat[i]*diet[i] >= 8;
/* read parameters */ read data fooddata into FOOD=[name] cost prot fat carb cal Moy;
/* solve and print the optimal solution */ solve with lp/logfreq=1; /* print each iteration to log */ print diet;
quit;
Please show the log for this program.
Thank you.
I found another way to make it work.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.