<?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 Proc OptModel Help on Maximize Correlation in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-OptModel-Help-on-Maximize-Correlation/m-p/42436#M350</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need your help. i am trying to maximize two variables' (dep and org*s) correlaton by changing the var (0&amp;lt;s&amp;lt;0.8). The below program (1st) works fine when i put [org*s] in the correlation formula. However, if i create a new variable, ads = org*s, the program doesn't work anymore. The reason i need to create a new variable ads is that there will be more calculations involved and i don't want to write an extreme long function in max procesure. i need to break out the long function to several pieces. i remember the old Proc NLP can do it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may be a very naiive question but do need your help. thx. Here are the two programs. Again, the 2nd doesn't work and i don't know how to fix it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fisher&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cor;&lt;/P&gt;&lt;P&gt;input org dep;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;11785895 7.42&lt;/P&gt;&lt;P&gt;2335492 7.58&lt;/P&gt;&lt;P&gt;2345245 7.58&lt;/P&gt;&lt;P&gt;2392912 7.53&lt;/P&gt;&lt;P&gt;12755890 7.63&lt;/P&gt;&lt;P&gt;2918402 7.67&lt;/P&gt;&lt;P&gt;2773183 7.68&lt;/P&gt;&lt;P&gt;2824198 7.65&lt;/P&gt;&lt;P&gt;12263433 7.53&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* program 1 that works;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;set w;&lt;/P&gt;&lt;P&gt;number org{w};&lt;/P&gt;&lt;P&gt;number ads{w};&lt;/P&gt;&lt;P&gt;number dep{w};&lt;/P&gt;&lt;P&gt;var s{w} &amp;gt;= 0 &amp;lt;= .8 init 1;&lt;/P&gt;&lt;P&gt;read data cor into w = [_n_] org dep;&lt;/P&gt;&lt;P&gt;max correlation = (10*sum{i in w}((org&lt;I&gt;*s&lt;I&gt;)*dep&lt;I&gt;) - (sum{i in w}((org&lt;I&gt;*s&lt;I&gt;))) * (sum{i in w}(dep&lt;I&gt;)))&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / (sqrt(10*sum{i in w}((org&lt;I&gt;*s&lt;I&gt;)^2) - (sum{i in w}((org&lt;I&gt;*s&lt;I&gt;)))^2) * sqrt(10*sum{i in w}(dep&lt;I&gt;^2) - (sum{i in w}(dep&lt;I&gt;))^2));&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;solve;&lt;/P&gt;&lt;P&gt;print s correlation;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* program 2 that doesn't work;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc optmodel;&lt;BR /&gt;set w;&lt;BR /&gt;number org{w};&lt;BR /&gt;number ads{w};&lt;BR /&gt;number dep{w};&lt;BR /&gt;var s{w} &amp;gt;= 0 &amp;lt;= .8 init 1;&lt;BR /&gt;read data cor into w = [_n_] org dep;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for {i in w} ads &lt;I&gt; = org &lt;I&gt; * s&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;max correlation = (10*sum{i in w}(ads&lt;I&gt;*dep&lt;I&gt;) - (sum{i in w}(ads&lt;I&gt;)) * (sum{i in w}(dep&lt;I&gt;)))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / (sqrt(10*sum{i in w}(ads&lt;I&gt;^2) - (sum{i in w}(ads&lt;I&gt;))^2) * sqrt(10*sum{i in w}(dep&lt;I&gt;^2) - (sum{i in w}(dep&lt;I&gt;))^2));&lt;BR /&gt;solve;&lt;BR /&gt;print s correlation;&lt;BR /&gt;quit;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 25 Mar 2012 03:20:45 GMT</pubDate>
    <dc:creator>hadesmr</dc:creator>
    <dc:date>2012-03-25T03:20:45Z</dc:date>
    <item>
      <title>Proc OptModel Help on Maximize Correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-OptModel-Help-on-Maximize-Correlation/m-p/42436#M350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need your help. i am trying to maximize two variables' (dep and org*s) correlaton by changing the var (0&amp;lt;s&amp;lt;0.8). The below program (1st) works fine when i put [org*s] in the correlation formula. However, if i create a new variable, ads = org*s, the program doesn't work anymore. The reason i need to create a new variable ads is that there will be more calculations involved and i don't want to write an extreme long function in max procesure. i need to break out the long function to several pieces. i remember the old Proc NLP can do it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may be a very naiive question but do need your help. thx. Here are the two programs. Again, the 2nd doesn't work and i don't know how to fix it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fisher&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cor;&lt;/P&gt;&lt;P&gt;input org dep;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;11785895 7.42&lt;/P&gt;&lt;P&gt;2335492 7.58&lt;/P&gt;&lt;P&gt;2345245 7.58&lt;/P&gt;&lt;P&gt;2392912 7.53&lt;/P&gt;&lt;P&gt;12755890 7.63&lt;/P&gt;&lt;P&gt;2918402 7.67&lt;/P&gt;&lt;P&gt;2773183 7.68&lt;/P&gt;&lt;P&gt;2824198 7.65&lt;/P&gt;&lt;P&gt;12263433 7.53&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* program 1 that works;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;set w;&lt;/P&gt;&lt;P&gt;number org{w};&lt;/P&gt;&lt;P&gt;number ads{w};&lt;/P&gt;&lt;P&gt;number dep{w};&lt;/P&gt;&lt;P&gt;var s{w} &amp;gt;= 0 &amp;lt;= .8 init 1;&lt;/P&gt;&lt;P&gt;read data cor into w = [_n_] org dep;&lt;/P&gt;&lt;P&gt;max correlation = (10*sum{i in w}((org&lt;I&gt;*s&lt;I&gt;)*dep&lt;I&gt;) - (sum{i in w}((org&lt;I&gt;*s&lt;I&gt;))) * (sum{i in w}(dep&lt;I&gt;)))&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / (sqrt(10*sum{i in w}((org&lt;I&gt;*s&lt;I&gt;)^2) - (sum{i in w}((org&lt;I&gt;*s&lt;I&gt;)))^2) * sqrt(10*sum{i in w}(dep&lt;I&gt;^2) - (sum{i in w}(dep&lt;I&gt;))^2));&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;solve;&lt;/P&gt;&lt;P&gt;print s correlation;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* program 2 that doesn't work;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc optmodel;&lt;BR /&gt;set w;&lt;BR /&gt;number org{w};&lt;BR /&gt;number ads{w};&lt;BR /&gt;number dep{w};&lt;BR /&gt;var s{w} &amp;gt;= 0 &amp;lt;= .8 init 1;&lt;BR /&gt;read data cor into w = [_n_] org dep;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for {i in w} ads &lt;I&gt; = org &lt;I&gt; * s&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;max correlation = (10*sum{i in w}(ads&lt;I&gt;*dep&lt;I&gt;) - (sum{i in w}(ads&lt;I&gt;)) * (sum{i in w}(dep&lt;I&gt;)))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / (sqrt(10*sum{i in w}(ads&lt;I&gt;^2) - (sum{i in w}(ads&lt;I&gt;))^2) * sqrt(10*sum{i in w}(dep&lt;I&gt;^2) - (sum{i in w}(dep&lt;I&gt;))^2));&lt;BR /&gt;solve;&lt;BR /&gt;print s correlation;&lt;BR /&gt;quit;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Mar 2012 03:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-OptModel-Help-on-Maximize-Correlation/m-p/42436#M350</guid>
      <dc:creator>hadesmr</dc:creator>
      <dc:date>2012-03-25T03:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc OptModel Help on Maximize Correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-OptModel-Help-on-Maximize-Correlation/m-p/42437#M351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In program 2, you have declared ads as a numeric parameter, so the resulting objective is constant.&amp;nbsp; Instead, you should declare ads as an implicit variable (and omit the FOR loop) as follows:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;impvar &lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;ads {i in w} = org &lt;I&gt; * s&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2012 17:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-OptModel-Help-on-Maximize-Correlation/m-p/42437#M351</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2012-03-26T17:01:08Z</dc:date>
    </item>
    <item>
      <title>Proc OptModel Help on Maximize Correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-OptModel-Help-on-Maximize-Correlation/m-p/42438#M352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks a lot RobPratt. It really helps. i may need to bother you again when i have more questions (high chance:))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fisher&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2012 17:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-OptModel-Help-on-Maximize-Correlation/m-p/42438#M352</guid>
      <dc:creator>hadesmr</dc:creator>
      <dc:date>2012-03-26T17:34:19Z</dc:date>
    </item>
  </channel>
</rss>

