<?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: Selecting the right volume based on weight and scores - Urgent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716585#M221488</link>
    <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your suggestion, I will give it ago &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And for the PROC OPTMODEL&amp;nbsp;, wasn't aware of it...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best wishes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Feb 2021 18:19:42 GMT</pubDate>
    <dc:creator>Question</dc:creator>
    <dc:date>2021-02-03T18:19:42Z</dc:date>
    <item>
      <title>Selecting the right volume based on weight and scores - Urgent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716510#M221454</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the table below and I would like to reach a sum of weight for example sum(weight)=12,933 (it could be any other number I am targeting)&amp;nbsp;and ideally I would like to pick the ones with the highest scores. I am wondering if there is a way of summing the column Weight till I reach 12,933 as an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your help would be much appreciated. I believe nothing is impossible in the programming world :-).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="424"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="107"&gt;Weight&lt;/TD&gt;
&lt;TD width="132"&gt;Region&lt;/TD&gt;
&lt;TD width="87"&gt;score&lt;/TD&gt;
&lt;TD width="98"&gt;decile&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1520&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.80164312&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2164&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.71899042&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1849&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.57949577&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1284&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.36499641&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1284&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.35679843&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1739&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.27635649&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1894&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.26110187&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1653&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.21283665&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1739&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.10142876&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1555&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.08766419&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1280&lt;/TD&gt;
&lt;TD&gt;North West&lt;/TD&gt;
&lt;TD&gt;0.08371918&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 03 Feb 2021 16:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716510#M221454</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2021-02-03T16:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the right volume based on weight and scores - Urgent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716514#M221456</link>
      <description>&lt;P&gt;You need to show what the expected result actually looks like.&lt;/P&gt;
&lt;P&gt;Also what are the rules when the target cannot be reached exactly? Does Region actually have any role in the calculation/selection? How about Decile? If so, you need to describe how they impact the process.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 16:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716514#M221456</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-03T16:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the right volume based on weight and scores - Urgent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716536#M221470</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for coming back...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I have a target volume per region like below....and each region will have weight, scores and deciles. Don't worry about decile etc , as long as I can get to the volume I need (sum of weight)&amp;nbsp;that would be good....if I do a cumulative sum of weight, it doesn't work...but summing them up&amp;nbsp;randomly I could reach almost my target. It doesn't have to be 100% match, as long as it is very close. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="265"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;&lt;STRONG&gt;Region&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="137"&gt;&lt;STRONG&gt;Target Volume (Sum of Weight)&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;East Midlands&lt;/TD&gt;
&lt;TD&gt;11,939&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;East of England&lt;/TD&gt;
&lt;TD&gt;14,070&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;London&lt;/TD&gt;
&lt;TD&gt;12,791&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;North East&lt;/TD&gt;
&lt;TD&gt;7,829&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;North West&lt;/TD&gt;
&lt;TD&gt;12,933&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;Northern Ireland&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;Scotland&lt;/TD&gt;
&lt;TD&gt;14,945&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;South East&lt;/TD&gt;
&lt;TD&gt;17,597&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;South West&lt;/TD&gt;
&lt;TD&gt;14,511&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;Wales&lt;/TD&gt;
&lt;TD&gt;5,704&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;West Midlands&lt;/TD&gt;
&lt;TD&gt;14,890&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="128"&gt;Yorks and the Humber&lt;/TD&gt;
&lt;TD&gt;10,526&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;Total&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;137,735&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 16:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716536#M221470</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2021-02-03T16:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the right volume based on weight and scores - Urgent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716548#M221478</link>
      <description>&lt;P&gt;How close is "close enough"?&lt;/P&gt;
&lt;P&gt;So how is score supposed to fit in?&lt;/P&gt;
&lt;P&gt;You need to show what you expect the output data set to look like.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 17:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716548#M221478</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-03T17:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the right volume based on weight and scores - Urgent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716549#M221479</link>
      <description>Would you prefer to match under or over? Wouldn't sorting descending and using a running total until you hit the desired amount work here?&lt;BR /&gt;Assuming your Target is in the same data set, if it's not merge it in first and ensure your data is sorted by region and descending weight.&lt;BR /&gt;&lt;BR /&gt;proc sort data=have; by region descending weight; run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by region descending weight;&lt;BR /&gt;&lt;BR /&gt;*holds value across rows;&lt;BR /&gt;retain running_total;&lt;BR /&gt;&lt;BR /&gt;*if first region re-set values to prevent prior data from affecting calcuations;&lt;BR /&gt;if first.region then do;&lt;BR /&gt;running_total = weight;&lt;BR /&gt;inclusion = 1;&lt;BR /&gt;end;&lt;BR /&gt;else if inclusion = 1 then do;&lt;BR /&gt;running_total = running_total + weight;&lt;BR /&gt;if running_total &amp;gt; target_weight then inclusion = 0;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;That's the brute force basic logic way. A slight improvement would be picking the value before the max and then finding the least amount after that would allow the sum to be closest to the target. &lt;BR /&gt;&lt;BR /&gt;Or try PROC OPTMODEL in SAS/OR if you have the correct license, but beyond my knowledge.&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Summing-to-a-target-value/td-p/707928" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Summing-to-a-target-value/td-p/707928&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Feb 2021 17:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716549#M221479</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-03T17:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the right volume based on weight and scores - Urgent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716585#M221488</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your suggestion, I will give it ago &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And for the PROC OPTMODEL&amp;nbsp;, wasn't aware of it...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best wishes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 18:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716585#M221488</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2021-02-03T18:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the right volume based on weight and scores - Urgent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716752#M221566</link>
      <description>&lt;P&gt;Thank you Reeza, the link you sent me solved my problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I've used a code that was in one of the conversations!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Wishes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 08:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-the-right-volume-based-on-weight-and-scores-Urgent/m-p/716752#M221566</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2021-02-04T08:26:56Z</dc:date>
    </item>
  </channel>
</rss>

