The following should work for you: /*Dataset with forecasts and actuals - expand as necessary*/ data inds; input Month FC1 FC2 FC3 AC; datalines; 1 111 125 120 118 2 208 151 183 172 3 157 166 155 154 4 202 215 199 209 run; proc optmodel; var w1, w2, w3; /*create a set of month - the values are read from the input dataset and will adapt to the changes in that*/ set<num> MONTHS; /*create number parameters running over the set of months*/ num FC1{MONTHS}; num FC2{MONTHS}; num FC3{MONTHS}; num AC{MONTHS}; /*Read the input data into the set and the parameters */ read data inds into MONTHS=[Month] FC1 FC2 FC3 AC; print FC1; /*summarize the error over each month and parameterize the forecasted and actual values*/ minimize absErr = sum{i in MONTHS} (abs(((w1*FC1[i])+(w2*FC2[i])+(w3*FC3[i]))-AC[i])); con bound1: w1+w2+w3=1; con bound2: max(w1,w2,w3)<= 1; con bound3: min(w1,w2,w3)>= 0; solve; print w1 w2 w3; /*create a simple output dataset with the value of the 3 variables*/ create data outds from w1 w2 w3; quit;
... View more