<?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: Excel Solver in sas in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Excel-Solver-in-sas/m-p/152210#M792</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC NLP is considered legacy and is no longer under active development.&amp;nbsp; You should instead use PROC OPTMODEL, and there is a book of examples here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ormpex/66850/HTML/default/viewer.htm#titlepage.htm" title="http://support.sas.com/documentation/cdl/en/ormpex/66850/HTML/default/viewer.htm#titlepage.htm"&gt;SAS/OR(R) 13.1 User's Guide: Mathematical Programming Examples&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If I understand your problem correctly, the following code does what you want:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data mydata;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input cust $ data1 data2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; datalines; &lt;BR /&gt;Cust1&amp;nbsp; 0.0128&amp;nbsp; 42815 &lt;BR /&gt;Cust2&amp;nbsp; 0.0128&amp;nbsp; 159541 &lt;BR /&gt;Cust3&amp;nbsp; 0.06&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 575796 &lt;BR /&gt;Cust4&amp;nbsp; 0.004&amp;nbsp; 256480 &lt;BR /&gt;Cust5&amp;nbsp; 0.003&amp;nbsp; 107 &lt;BR /&gt;Cust6&amp;nbsp; 0.002&amp;nbsp; 174744 &lt;BR /&gt;Cust7&amp;nbsp; 0.0128&amp;nbsp; 336044 &lt;BR /&gt;Cust8&amp;nbsp; 0.0128&amp;nbsp; 17032 &lt;BR /&gt;Cust9&amp;nbsp; 0.0128&amp;nbsp; 314733 &lt;BR /&gt;Cust10 0.003&amp;nbsp; 217724 &lt;BR /&gt;Cust11 0.0128&amp;nbsp; 219205 &lt;BR /&gt;Cust12 0.0104&amp;nbsp; 452909 &lt;BR /&gt;Cust13 0.0105&amp;nbsp; 4263 &lt;BR /&gt;Cust14 0.0128&amp;nbsp; 230952 &lt;BR /&gt;Cust15 0.07&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 34579 &lt;BR /&gt;Cust16 0.0128&amp;nbsp; 197932 &lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set CUSTOMERS;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; str cust {CUSTOMERS};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num data1 {CUSTOMERS};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num data2 {CUSTOMERS};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; read data mydata into CUSTOMERS=[_N_] cust data1 data2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; num wa = 0.018;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num n&amp;nbsp; = 4000000;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; var X {CUSTOMERS} &amp;gt;= 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; con Cardinality:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum {i in CUSTOMERS} X&lt;I&gt; = n;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; con WeightedAverage:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum {i in CUSTOMERS} data1&lt;I&gt; * X&lt;I&gt; = wa * sum {i in CUSTOMERS} X&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; min Error = sum {i in CUSTOMERS} (X&lt;I&gt; - data2&lt;I&gt;)^2;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; solve;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print cust data2 X;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put (sum {i in CUSTOMERS} data2&lt;I&gt;)=;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; put ((sum {i in CUSTOMERS} data1&lt;I&gt; * data2&lt;I&gt;)/sum {i in CUSTOMERS} data2&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; put (sum {i in CUSTOMERS} X&lt;I&gt;)=;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; put ((sum {i in CUSTOMERS} data1&lt;I&gt; * X&lt;I&gt;)/sum {i in CUSTOMERS} X&lt;I&gt;)=;&lt;BR /&gt;quit;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The resulting optimal objective is 39,236,599,668, which is smaller than the sum of squares 40,718,058,821 attained by your solution in the "Optimal" column, so maybe I have misinterpreted your problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jan 2014 17:47:34 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2014-01-24T17:47:34Z</dc:date>
    <item>
      <title>Excel Solver in sas</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Excel-Solver-in-sas/m-p/152209#M791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new enough to sas, and I want to create a code in sas similar to the excel solver tool in the attached example. The weighted average of data1 and data2 is 2%. However if the sum of data 2 increased to 4m, what would be the optimal split by customer to get a weighted average of 1.8%. I have seen other post that say using PROC NLP is the best way to go, however I am not sure where to start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2014 16:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Excel-Solver-in-sas/m-p/152209#M791</guid>
      <dc:creator>nw2014</dc:creator>
      <dc:date>2014-01-24T16:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Excel Solver in sas</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Excel-Solver-in-sas/m-p/152210#M792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC NLP is considered legacy and is no longer under active development.&amp;nbsp; You should instead use PROC OPTMODEL, and there is a book of examples here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ormpex/66850/HTML/default/viewer.htm#titlepage.htm" title="http://support.sas.com/documentation/cdl/en/ormpex/66850/HTML/default/viewer.htm#titlepage.htm"&gt;SAS/OR(R) 13.1 User's Guide: Mathematical Programming Examples&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If I understand your problem correctly, the following code does what you want:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data mydata;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input cust $ data1 data2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; datalines; &lt;BR /&gt;Cust1&amp;nbsp; 0.0128&amp;nbsp; 42815 &lt;BR /&gt;Cust2&amp;nbsp; 0.0128&amp;nbsp; 159541 &lt;BR /&gt;Cust3&amp;nbsp; 0.06&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 575796 &lt;BR /&gt;Cust4&amp;nbsp; 0.004&amp;nbsp; 256480 &lt;BR /&gt;Cust5&amp;nbsp; 0.003&amp;nbsp; 107 &lt;BR /&gt;Cust6&amp;nbsp; 0.002&amp;nbsp; 174744 &lt;BR /&gt;Cust7&amp;nbsp; 0.0128&amp;nbsp; 336044 &lt;BR /&gt;Cust8&amp;nbsp; 0.0128&amp;nbsp; 17032 &lt;BR /&gt;Cust9&amp;nbsp; 0.0128&amp;nbsp; 314733 &lt;BR /&gt;Cust10 0.003&amp;nbsp; 217724 &lt;BR /&gt;Cust11 0.0128&amp;nbsp; 219205 &lt;BR /&gt;Cust12 0.0104&amp;nbsp; 452909 &lt;BR /&gt;Cust13 0.0105&amp;nbsp; 4263 &lt;BR /&gt;Cust14 0.0128&amp;nbsp; 230952 &lt;BR /&gt;Cust15 0.07&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 34579 &lt;BR /&gt;Cust16 0.0128&amp;nbsp; 197932 &lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set CUSTOMERS;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; str cust {CUSTOMERS};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num data1 {CUSTOMERS};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num data2 {CUSTOMERS};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; read data mydata into CUSTOMERS=[_N_] cust data1 data2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; num wa = 0.018;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num n&amp;nbsp; = 4000000;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; var X {CUSTOMERS} &amp;gt;= 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; con Cardinality:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum {i in CUSTOMERS} X&lt;I&gt; = n;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; con WeightedAverage:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum {i in CUSTOMERS} data1&lt;I&gt; * X&lt;I&gt; = wa * sum {i in CUSTOMERS} X&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; min Error = sum {i in CUSTOMERS} (X&lt;I&gt; - data2&lt;I&gt;)^2;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; solve;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; print cust data2 X;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put (sum {i in CUSTOMERS} data2&lt;I&gt;)=;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; put ((sum {i in CUSTOMERS} data1&lt;I&gt; * data2&lt;I&gt;)/sum {i in CUSTOMERS} data2&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; put (sum {i in CUSTOMERS} X&lt;I&gt;)=;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; put ((sum {i in CUSTOMERS} data1&lt;I&gt; * X&lt;I&gt;)/sum {i in CUSTOMERS} X&lt;I&gt;)=;&lt;BR /&gt;quit;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The resulting optimal objective is 39,236,599,668, which is smaller than the sum of squares 40,718,058,821 attained by your solution in the "Optimal" column, so maybe I have misinterpreted your problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jan 2014 17:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Excel-Solver-in-sas/m-p/152210#M792</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2014-01-24T17:47:34Z</dc:date>
    </item>
  </channel>
</rss>

