Portfolio Optimization (optqp2)
/***************************************************************/
/* */
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: optqp2 */
/* TITLE: Portfolio Optimization (optqp2) */
/* PRODUCT: OR */
/* SYSTEM: ALL */
/* KEYS: OR */
/* PROCS: OPTQP */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: Example 2 from the OPTQP chapter of */
/* Mathematical Programming. */
/* */
/***************************************************************/
data portdata;
input field1 $ field2 $ field3 $ field4 field5 $ field6 @;
datalines;
NAME . PORT . . .
ROWS . . . . .
N OBJ.FUNC . . . .
L BUDGET . . . .
G GROWTH . . . .
COLUMNS . . . . .
. X1 BUDGET 1.0 GROWTH 0.05
. X2 BUDGET 1.0 GROWTH -.20
. X3 BUDGET 1.0 GROWTH 0.15
. X4 BUDGET 1.0 GROWTH 0.30
RHS . . . . .
. RHS BUDGET 10000 . .
. RHS GROWTH 1000 . .
RANGES . . . . .
BOUNDS . . . . .
QUADOBJ . . . . .
. X1 X1 0.16 . .
. X1 X2 -.10 . .
. X1 X3 -.10 . .
. X1 X4 -.10 . .
. X2 X2 0.32 . .
. X2 X3 -.04 . .
. X2 X4 -.04 . .
. X3 X3 0.70 . .
. X3 X4 0.12 . .
. X4 X4 0.70 . .
ENDATA . . . . .
;
title1 'The OPTQP Procedure';
proc optqp data=portdata
primalout = portpout
printlevel = 0
dualout = portdout;
run;
title2 'Primal Solution';
proc print data=portpout label;
run;
data possdata;
input field1 $ field2 $ field3 $ field4 field5 $ field6 @;
datalines;
NAME . PORTSS . . .
ROWS . . . . .
N OBJ.FUNC . . . .
L R1 . . . .
G R2 . . . .
COLUMNS . . . . .
. X1 R1 1.0 R2 0.05
. X2 R1 1.0 R2 -.20
. X3 R1 1.0 R2 0.15
. X4 R1 1.0 R2 0.30
RHS . . . . .
. RHS R1 10000 . .
. RHS R2 1000 . .
RANGES . . . . .
BOUNDS . . . . .
FR BND1 X1 . . .
FR BND1 X2 . . .
FR BND1 X3 . . .
FR BND1 X4 . . .
QUADOBJ . . . . .
. X1 X1 0.16 . .
. X1 X2 -.10 . .
. X1 X3 -.10 . .
. X1 X4 -.10 . .
. X2 X2 0.32 . .
. X2 X3 -.04 . .
. X2 X4 -.04 . .
. X3 X3 0.70 . .
. X3 X4 0.12 . .
. X4 X4 0.70 . .
ENDATA . . . . .
;
title1 'The OPTQP Procedure';
proc optqp data=possdata
primalout = posspout
printlevel = 0
dualout = possdout;
run;
title2 'Primal Solution';
proc print data=posspout label;
run;