<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: proc optmodel in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel/m-p/490122#M2390</link>
    <description>&lt;P&gt;The linked example illustrates a single BY variable.&amp;nbsp; One approach for your pair of BY variables is to introduce a new variable that concatenates the two&amp;nbsp;and then use that new variable as your BY variable.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Aug 2018 15:33:25 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2018-08-27T15:33:25Z</dc:date>
    <item>
      <title>proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel/m-p/489790#M2385</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have the following type of dataset and have as many as 4000 permnos.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am trying to do the following ,&lt;/P&gt;&lt;PRE&gt;min VAR(R.dr - SUM[w_i * R.s_i]) = min VAR(Dr - w*S)
  s.t. SUM(w_i) = 1; w_i &amp;gt; 0&lt;BR /&gt;(R.s_i include rmrf hml smb)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="test.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22777iBCED64AC02C34E45/image-size/large?v=v2&amp;amp;px=999" role="button" title="test.png" alt="test.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am using the following code for this. The code works perfectly fine,when I run it for one permno only but I want to run this using a by variable (by permno&amp;nbsp;and month). I am not sure how to incorporate this, I have read this document (&lt;A href="http://support.sas.com/kb/42/332.html" target="_blank"&gt;http://support.sas.com/kb/42/332.html&lt;/A&gt;) but I am not getting how to apply this on my data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help would be much appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc corr data=return1 (drop=date)
   out=corrout(where=(_type_ ne 'CORR')) cov noprint;
  
run;

data stats(drop=_name_);
   set corrout;
   if _type_ = 'COV' then delete;
run;
proc transpose data=stats out=stats;
   id _type_;
run;


proc optmodel;
   /* declare parameters and read data */
   set &amp;lt;str&amp;gt; ASSETS;
   str target = 'f';
   set BENCH = ASSETS diff {target};
   num cov {ASSETS, ASSETS};
   read data stats into ASSETS=[_name_];
   read data corrout(where=(_type_='COV')) into [_name_]
      {i in ASSETS} &amp;lt;cov[_name_,i]=col(i)&amp;gt;;
/* let w1, w2, w3, w4 be the amount invested in each asset */
   var x{1..4} &amp;gt;= 0;
   /* declare optimization model */
   var W {BENCH} &amp;gt;= 0 &amp;lt;= 1;
   /* Var(X - Y) = Var(X) + Var(Y) - 2 Cov(X,Y) */
   min Variance = 
      sum {i in BENCH, j in BENCH} cov[i,j] * W[i] * W[j]
    + cov[target,target] 
    - 2 * sum {i in BENCH} cov[i,target] * W[i];
	/* subject to the following constraints */
    con weights:  sum {i in BENCH} W[i] = 1;

   /* call solver and print optimal solution */
   solve;
   print W;
quit;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Aug 2018 00:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel/m-p/489790#M2385</guid>
      <dc:creator>Amalik</dc:creator>
      <dc:date>2018-08-25T00:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel/m-p/490122#M2390</link>
      <description>&lt;P&gt;The linked example illustrates a single BY variable.&amp;nbsp; One approach for your pair of BY variables is to introduce a new variable that concatenates the two&amp;nbsp;and then use that new variable as your BY variable.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 15:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel/m-p/490122#M2390</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-08-27T15:33:25Z</dc:date>
    </item>
  </channel>
</rss>

