<?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 HELP: Proc OptModel to simplify constrains in max correlation in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50041#M371</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Hi all, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;This is a follow-up question to my last post. Basically, i need to maximize the correlation between 'ads' and 'dep' by changing the variable 's' with some constrains. Thanks for RobPratt's help that i was able to achieve this optimization without constrains. Now i need to put the constrains in.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The constrains need to follow a simple rule: same value repeating for every 8 observations. In other words, &lt;SPAN style="text-decoration: underline;"&gt;s[1] = s[2] = .....s[7] = s [8]&lt;/SPAN&gt;,&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;s[9] = s[10] = .....s[16],&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;s[17] = s[18] = s[19&lt;/SPAN&gt;]. i wrote a very elementary constrains in my program but looks like it didn't work quite well. My main two questions are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Why s[1] to s[0] are all 0? I must did something wrong. (s[9] to s[19] looks ok.). Pls refer to the SAS output below the program.&lt;/P&gt;&lt;P&gt;2. Any macro or creative way to simplify my constrains? In the real data set, there will be hundreds of observations that are still needed to repeat in 8. I don't want to kill myself to manually write one by one &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HY&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;--------------------------------------------&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;data cor;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;input org dep;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;11785895 7.42&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2335492 7.58&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2345245 7.58&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2392912 7.53&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;12755890 7.63&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2918402 7.67&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2773183 7.68&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2824198 7.65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;12263433 7.53&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2420611 7.53&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2338870 7.63&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2268830 7.74&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2462173 7.74&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;10775045 7.80&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2834195 7.75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2666271 7.55&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2734586 7.65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;11722258 7.60&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2366007 7.71&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;%let wk = 19;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;proc optmodel;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;set w;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;number org{w};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;number dep{w};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;var s{w} &amp;gt;= 0 &amp;lt;= .8 init 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;impvar ads{i in w} = org&lt;I&gt; * s&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;read data work.cor into w = [_n_] org dep;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;max correlation = (&amp;amp;wk*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;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / (sqrt(&amp;amp;wk*sum{i in w}(ads&lt;I&gt;^2) - (sum{i in w}(ads&lt;I&gt;))^2) * sqrt(&amp;amp;wk*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;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&amp;nbsp; &lt;STRONG style="color: #ff0000;"&gt;&amp;nbsp; con s[1]=s[2], s[2]=s[3], s[3]=s[4], s[4]=s[5], s[5]=s[6], s[6]=s[7], s[7]=s[8];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;STRONG style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; con s[9]=s[10], s[10]=s[11], s[11]=s[12], s[12]=s[13], s[13]=s[14], s[14]=s[15], s[15]=s[16];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;STRONG style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; con s[17]=s[18], s[18]=s[19];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;solve;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;print s ads correlation;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;SAS Output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;DIV&gt;&lt;P&gt;[1] s ads&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;1 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;2 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;3 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;4 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;5 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;6 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;7 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;8 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;9 0.0084904 104120.9&lt;/P&gt;&lt;P&gt;10 0.0084904 20551.8&lt;/P&gt;&lt;P&gt;11 0.0084904 19857.8&lt;/P&gt;&lt;P&gt;12 0.0084904 19263.2&lt;/P&gt;&lt;P&gt;13 0.0084904 20904.7&lt;/P&gt;&lt;P&gt;14 0.0084904 91483.9&lt;/P&gt;&lt;P&gt;15 0.0084904 24063.3&lt;/P&gt;&lt;P&gt;16 0.0084904 22637.6&lt;/P&gt;&lt;P&gt;17 0.0006025 1647.6&lt;/P&gt;&lt;P&gt;18 0.0006025 7062.6&lt;/P&gt;&lt;P&gt;19 0.0006025 1425.5&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;correlation&lt;/P&gt;&lt;/DIV&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;0.16488&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Mar 2012 15:00:02 GMT</pubDate>
    <dc:creator>hadesmr</dc:creator>
    <dc:date>2012-03-30T15:00:02Z</dc:date>
    <item>
      <title>HELP: Proc OptModel to simplify constrains in max correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50041#M371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Hi all, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;This is a follow-up question to my last post. Basically, i need to maximize the correlation between 'ads' and 'dep' by changing the variable 's' with some constrains. Thanks for RobPratt's help that i was able to achieve this optimization without constrains. Now i need to put the constrains in.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The constrains need to follow a simple rule: same value repeating for every 8 observations. In other words, &lt;SPAN style="text-decoration: underline;"&gt;s[1] = s[2] = .....s[7] = s [8]&lt;/SPAN&gt;,&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;s[9] = s[10] = .....s[16],&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;s[17] = s[18] = s[19&lt;/SPAN&gt;]. i wrote a very elementary constrains in my program but looks like it didn't work quite well. My main two questions are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Why s[1] to s[0] are all 0? I must did something wrong. (s[9] to s[19] looks ok.). Pls refer to the SAS output below the program.&lt;/P&gt;&lt;P&gt;2. Any macro or creative way to simplify my constrains? In the real data set, there will be hundreds of observations that are still needed to repeat in 8. I don't want to kill myself to manually write one by one &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HY&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;--------------------------------------------&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;data cor;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;input org dep;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;11785895 7.42&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2335492 7.58&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2345245 7.58&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2392912 7.53&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;12755890 7.63&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2918402 7.67&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2773183 7.68&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2824198 7.65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;12263433 7.53&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2420611 7.53&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2338870 7.63&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2268830 7.74&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2462173 7.74&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;10775045 7.80&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2834195 7.75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2666271 7.55&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2734586 7.65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;11722258 7.60&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;2366007 7.71&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;%let wk = 19;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;proc optmodel;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;set w;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;number org{w};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;number dep{w};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;var s{w} &amp;gt;= 0 &amp;lt;= .8 init 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;impvar ads{i in w} = org&lt;I&gt; * s&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;read data work.cor into w = [_n_] org dep;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;max correlation = (&amp;amp;wk*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;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / (sqrt(&amp;amp;wk*sum{i in w}(ads&lt;I&gt;^2) - (sum{i in w}(ads&lt;I&gt;))^2) * sqrt(&amp;amp;wk*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;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&amp;nbsp; &lt;STRONG style="color: #ff0000;"&gt;&amp;nbsp; con s[1]=s[2], s[2]=s[3], s[3]=s[4], s[4]=s[5], s[5]=s[6], s[6]=s[7], s[7]=s[8];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;STRONG style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; con s[9]=s[10], s[10]=s[11], s[11]=s[12], s[12]=s[13], s[13]=s[14], s[14]=s[15], s[15]=s[16];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;STRONG style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; con s[17]=s[18], s[18]=s[19];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;solve;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;print s ads correlation;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;SAS Output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;&lt;DIV&gt;&lt;P&gt;[1] s ads&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;1 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;2 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;3 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;4 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;5 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;6 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;7 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;8 0.0000000 0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;9 0.0084904 104120.9&lt;/P&gt;&lt;P&gt;10 0.0084904 20551.8&lt;/P&gt;&lt;P&gt;11 0.0084904 19857.8&lt;/P&gt;&lt;P&gt;12 0.0084904 19263.2&lt;/P&gt;&lt;P&gt;13 0.0084904 20904.7&lt;/P&gt;&lt;P&gt;14 0.0084904 91483.9&lt;/P&gt;&lt;P&gt;15 0.0084904 24063.3&lt;/P&gt;&lt;P&gt;16 0.0084904 22637.6&lt;/P&gt;&lt;P&gt;17 0.0006025 1647.6&lt;/P&gt;&lt;P&gt;18 0.0006025 7062.6&lt;/P&gt;&lt;P&gt;19 0.0006025 1425.5&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;correlation&lt;/P&gt;&lt;/DIV&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;0.16488&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 15:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50041#M371</guid>
      <dc:creator>hadesmr</dc:creator>
      <dc:date>2012-03-30T15:00:02Z</dc:date>
    </item>
    <item>
      <title>HELP: Proc OptModel to simplify constrains in max correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50042#M372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see anything wrong with s[1] = ... = s[8] = 0.&amp;nbsp; That is feasible to your bounds and constraints.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the following CON statement to declare your constraints:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con c {i in w diff {card(w)}: mod(i,8) ne 0}: s&lt;I&gt; = s[i+1];&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, you can omit the constraints and declare only three s variables in the first place:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var s{1..ceil(card(w)/8)} &amp;gt;= 0 &amp;lt;= .8 init 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; impvar ads{i in w} = org&lt;I&gt; * s[ceil(i/8)];&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 15:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50042#M372</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2012-03-30T15:31:56Z</dc:date>
    </item>
    <item>
      <title>HELP: Proc OptModel to simplify constrains in max correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50043#M373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so very much RobPratt! You are my hero:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a good weekend!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 19:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50043#M373</guid>
      <dc:creator>hadesmr</dc:creator>
      <dc:date>2012-03-30T19:08:59Z</dc:date>
    </item>
    <item>
      <title>HELP: Proc OptModel to simplify constrains in max correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50044#M374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey RobPratt, one more question for you. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;does the label name in input statement need to be exact same to those in 'read data" part in proc optmodel? In the below example, should "org" and "dep" be consistent in input and read data?&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;data cor;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;input &lt;STRONG&gt;org dep&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;read data work.cor into w = [_n_]&lt;STRONG&gt; org dep&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 19:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50044#M374</guid>
      <dc:creator>hadesmr</dc:creator>
      <dc:date>2012-03-31T19:37:50Z</dc:date>
    </item>
    <item>
      <title>HELP: Proc OptModel to simplify constrains in max correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50045#M375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; by the way, which one of your two solutions (w constrains and w/o) runs more efficiently in sas assuming i will run hundreds of times using macro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 19:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50045#M375</guid>
      <dc:creator>hadesmr</dc:creator>
      <dc:date>2012-03-31T19:55:19Z</dc:date>
    </item>
    <item>
      <title>HELP: Proc OptModel to simplify constrains in max correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50046#M376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, the names do not have to be the same.&amp;nbsp; If they are different, say org1 and dep1 in the data set, then you can use org=org1 dep=dep1 in the READ DATA statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 20:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50046#M376</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2012-03-31T20:13:16Z</dc:date>
    </item>
    <item>
      <title>HELP: Proc OptModel to simplify constrains in max correlation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50047#M377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The second version (with fewer variables and no constraints) is more efficient.&amp;nbsp; Also, depending on how different your hundreds of runs are, you might be better off doing all the looping within one PROC OPTMODEL session, instead of calling PROC OPTMODEL hundreds of times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 20:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/HELP-Proc-OptModel-to-simplify-constrains-in-max-correlation/m-p/50047#M377</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2012-03-31T20:16:08Z</dc:date>
    </item>
  </channel>
</rss>

