N/A
Posts: 1

# Run PROC OPTMODEL on each row/obs

The data set is as below:

 Obs Aret Bret Astdev Bstdev Corr 1 0.12 0.03 0.21 0.02 0.31 2 0.09 0.06 0.18 0.07 0.54 ...... 100 0.11 0.04 0.17 0.02 0.44

Basically I have expected returns, stdev and correlation of two stocks A & B for 100 years. From these two stocks, I have to construct a portfolio with min variance for each year=> 100 optimal portfolios. =>Then I have to print out the optimization results for all 100 optimizations in one table.

Could you please give my some suggestions/ comments?

Here is my attempt:

%macro MVP_OPT(100);

%do i=1 %to &100 by 1;

R%i=(1 Corr%i, Corr%i 1);

C%i=(Astdev%i, Bstdev%i);

D%i=diag(C%i);

S%i = D%i*R%i*D%i; /** covariance matrix **/

W%i=( Bweight%i, 1-Aweight%i);

Transw%i=t(W%i);

proc optmodel;

var Aweight%i>=0, 1-Aweight%i>=0;

min f= Transw%i*S%i*W%i /**find min of portfolio variance**/

solve with qp;

run;

%end;

%mend MVP_OPT;

%print Aweight;

Thanks a bunch!!!!

J.Z.

SAS Employee
Posts: 527

## Re: Run PROC OPTMODEL on each row/obs

Questions about PROC OPTMODEL in SAS/OR are better suited for the Mathematical Optimization and Operations Research Community.  If you still need help, please post there.

Discussion stats