Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

problems with the ordering of IMPVAR declarations in Proc Optmodel

Reply
Contributor
Posts: 22

problems with the ordering of IMPVAR declarations in Proc Optmodel

I am having some problems with the ordering of IMPVAR declarations in Proc Optmodel.  SAS will not allow me to define an IMPVAR based on a later defined IMPVAR. This is problematic because many of the IMPVAR that I need to define are mutually dependent.  I thought I may be able to create a loop to overcome this, but I receive a message stating that IMPVAR declarations are not allowed within a nested statement.  I can create equivalent statements in Proc IML with Do loops, and I am wondering if there is a similar solution.  The log file is pasted below, and I have attached the program file.


677  proc optmodel PRINTLEVEL=0;

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE OPTMODEL used (Total process time):

      real time           1:38.02

      cpu time            12.41 seconds

678

679      *create a numerical index based on permno and date, read in below;

680      set <num,num> STOCKS_DATES;

681      *create another numerical index just based on dates;

682      set DATES = setof {<i,t> in STOCKS_DATES} t;

683      *create another numerical index just based on permnos;

684      set STOCKS {t in DATES} = slice(<*,t>, STOCKS_DATES);

685      *create a numerical index based on the characteristics upon which portfolio

685! weights are based;

686      set CHARACTERISTICS = {'alpha', 'beta', 'stdfirm'};

687

688      *name variables that will be read in from the data set;

689      num char {STOCKS_DATES, CHARACTERISTICS};

690      num ret {STOCKS_DATES};

691

692      *read in the sas data set, specifying that each column in the char matrix is a

692! different characteristic, k;

693      read data foriml into STOCKS_DATES=[permno obs]

694          {k in CHARACTERISTICS} <char[permno,obs,k]=col(k)>

695          ret;

NOTE: There were 1672103 observations read from the data set WORK.FORIML.

696

697      var Theta {CHARACTERISTICS} init 0;

698

699      impvar W {<i,t> in STOCKS_DATES} = (1/card(STOCKS)) + (1/card(STOCKS)) *

699! sum {k in CHARACTERISTICS} Theta * char[i,t,k];

700

701      impvar portwmlin {t in DATES} = sum {i in STOCKS} W[i,t] * ret[i,t];

702

703      impvar portmean = (1/card(DATES)) * (sum {t in DATES} portwmlin);

704

705      impvar portvar = (1/card(DATES)) * (sum {t in DATES}((portwmlin-portmean)**2))

705! ;

706

707      max Objective1 = portmean - (&y/2) * portvar;

708

709  Problem Prob1 Include Theta Objective1;

710

711      var kay init 0;

712

713      impvar beg_W{<i,t> in STOCKS_DATES} = if <i,t-1> in STOCKS_DATES then

713! actual_W[i,t-1]*((1+ret[i,t-1])/(1+portntin[t-1])) else 0;

     --------

     537

ERROR 537-782: The symbol 'actual_W' is unknown.

713! actual_W[i,t-1]*((1+ret[i,t-1])/(1+portntin[t-1])) else 0;

                                        --------

                                        537

ERROR 537-782: The symbol 'portntin' is unknown.

714

715      impvar distance  {t in DATES} = (1/card(STOCKS)) * sum {i in

715! STOCKS}((W[i,t]-beg_W[i,t])^2);

716

717      impvar alpha {t in DATES} = (kay*sqrt(card(STOCKS)))/ sqrt(sum {i in

717! STOCKS}((W[i,t]-beg_W[i,t])^2));

718

719      impvar actual_W {<i,t> in STOCKS_DATES} = if distance <= kay^2 then beg_W[i,t]

719!  else alpha * beg_W[i,t] + (1-alpha) * W[i,t];

720

721      impvar portntin {t in DATES} = sum {i in STOCKS} (actual_W[i,t] * ret[i,t] +

721! 0.005 * abs(actual_W[i,t]-beg_W[i,t]));

722

723      impvar portntmean = (1/card(DATES)) * (sum {t in DATES} portntin);

724

725      impvar portntvar = (1/card(DATES)) * (sum {t in

725! DATES}((portntin-portntmean)**2));

726

727      max Objective2 = portntmean - (&y/2) * portntvar;

728

729  Problem Prob2 Include kay Objective2;



Attachment
Attachment
Ask a Question
Discussion stats
  • 0 replies
  • 437 views
  • 0 likes
  • 1 in conversation