I'm trying to optimize a football team in PROC OPTMODEL. I've successfully created the code which produces the report, but I want to save my decision variables outcome into a dataset. I read the following SAS documentation which suggests to use 'create data' statement, but I'm very new to PROC OPTMODEL and I'm not able to get the expected output. The code is as follows: proc optmodel;
set <string> PLAYERS;
set <string> DEF = {"Alonso", "Azpilicueta", "Cahill", "Christensen", "David Luiz", "Emerson", "Moses", "Rudiger", "Zappacosta"};
set <string> FWD = {"Abraham","Giroud","Morata"};
set <string> GKP = {"Caballero","Courtois","Kepa"};
set <string> MID = {"Ampadu", "Bakayoko", "Barkley", "Drinkwater", "Fabregas", "Hazard", "Hudson-Odoi", "Jorginho", "Kante", "Kovacic", "Loftus-Cheek", "Pedro", "Willian"};
set <string> WeekMatch;
number NewPoints{PLAYERS};
number threshold{WeekMatch};
read data WORK.PLAYERS into PLAYERS = [Name] NewPoints;
read data WORK.THRESH into WeekMatch = [week] threshold;
var x{PLAYERS, WeekMatch} binary;
var win{WeekMatch} binary;
Maximize numberofwin = sum {i in WeekMatch} win[i];
/*constraint on maximum number of times a player can play*/
con ConsecutivePlay {i in PLAYERS}: sum {j in WeekMatch} x[i,j] <= 25;
/*opponent threshold constraint*/
con WinTotal {j in WeekMatch} : sum {i in PLAYERS} x[i,j] * NewPoints[i] >= threshold[j] * win[j];
/*position constraints*/
con weekDEF {j in WeekMatch} : sum {i in DEF} x[i,j] = 4;
con weekFWD {j in WeekMatch} : sum {i in FWD} x[i,j] = 1;
con weekGKP {j in WeekMatch} : sum {i in GKP} x[i,j] = 1;
con weekMID {j in WeekMatch} : sum {i in MID} x[i,j] = 5;
solve with milp;
print numberofwin x win;
create data numberofwin from count=numberofwin;
quit; The supporting data is attached.
... View more