<?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: Making work queues of equal sizes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401439#M97397</link>
    <description>&lt;P&gt;If the issue is to assign your jobs into 4 bins then sort the data by the runtime and then apply a bin number using MOD function based on order in the data set.&lt;/P&gt;
&lt;P&gt;The below example creates 100 records in sorted order. Think of the value as runtime order. The mod function would return 0 to 3 with mod 4, so I add 1 in case 0 isn't an acceptable bin number. You could sum the runtimes with the bin as a class variable to see the expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   do i=1 to 100;
      output;
   end;
run;

data want;
   set have;
   bin = mod(_n_,4)+1;
run;&lt;/PRE&gt;
&lt;P&gt;If you have SAS/OR licensed I suspect that you could get a better balance but I suspect&amp;nbsp; this approach may be "good enough" unless you have one or two jobs that run orders of magnitude longer than most of the others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2017 16:48:39 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-10-05T16:48:39Z</dc:date>
    <item>
      <title>Making work queues of equal sizes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401435#M97395</link>
      <description>&lt;P&gt;Explanation:&lt;/P&gt;&lt;P&gt;SAS 9.4 m4&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've got about 100 pieces of work to accomplish. I know what the average run time is for each piece of work. I have only 4 connections to my database and I want to make the work run optimally. I tried proc hpbin but it does not do what I really want, but does give you an idea of my data.&lt;BR /&gt;&lt;BR /&gt;proc hpbin data=work.hbin_data output=work.binout numbin=4 bucket;&lt;BR /&gt;id job_nm jobwall_p95;&lt;BR /&gt;input jobwall_p95;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;I then write a proc summary to see how it did and I have 4 queues, but they are not close to being equal as that not what HPBIN does.&lt;/P&gt;&lt;P&gt;BIN&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JOBWALL_P95_Sum&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;JOBWALL_P95_N&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 378.66666667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;77&lt;BR /&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 129.81666667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 173.71666667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 132.06666667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, HPBIN makes 4 bins with the first one that runs small jobs and takes 378 seconds&lt;/P&gt;&lt;P&gt;Please help?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 16:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401435#M97395</guid>
      <dc:creator>DASDguy</dc:creator>
      <dc:date>2017-10-05T16:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Making work queues of equal sizes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401439#M97397</link>
      <description>&lt;P&gt;If the issue is to assign your jobs into 4 bins then sort the data by the runtime and then apply a bin number using MOD function based on order in the data set.&lt;/P&gt;
&lt;P&gt;The below example creates 100 records in sorted order. Think of the value as runtime order. The mod function would return 0 to 3 with mod 4, so I add 1 in case 0 isn't an acceptable bin number. You could sum the runtimes with the bin as a class variable to see the expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   do i=1 to 100;
      output;
   end;
run;

data want;
   set have;
   bin = mod(_n_,4)+1;
run;&lt;/PRE&gt;
&lt;P&gt;If you have SAS/OR licensed I suspect that you could get a better balance but I suspect&amp;nbsp; this approach may be "good enough" unless you have one or two jobs that run orders of magnitude longer than most of the others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 16:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401439#M97397</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-05T16:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Making work queues of equal sizes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401501#M97422</link>
      <description>&lt;P&gt;My problem is that some jobs take .06 seconds and other take over 100. So, there is quite some disparity there. I don't have SAS/OR. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 20:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401501#M97422</guid>
      <dc:creator>DASDguy</dc:creator>
      <dc:date>2017-10-05T20:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Making work queues of equal sizes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401531#M97433</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169764"&gt;@DASDguy&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;My problem is that some jobs take .06 seconds and other take over 100. So, there is quite some disparity there. I don't have SAS/OR. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;On second though the mod approach, will tend to have the 4th bin run longer.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;data junk;
   incr= 1;
   do i = 1 to 100;
      bin+incr;
      if bin=5 then do;
         incr= -1;
         bin=4;
      end;
      if bin=0 then do;
         incr= 1;
         bin=1;
      end;
      output;
   end;
run;

proc means data=junk nway sum;
   class bin;
   var i;
run;&lt;/PRE&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>Thu, 05 Oct 2017 22:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/401531#M97433</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-05T22:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Making work queues of equal sizes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/402467#M97734</link>
      <description>&lt;P&gt;The method of "snake drafting" is good enough for my purposes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 18:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-work-queues-of-equal-sizes/m-p/402467#M97734</guid>
      <dc:creator>DASDguy</dc:creator>
      <dc:date>2017-10-09T18:49:27Z</dc:date>
    </item>
  </channel>
</rss>

