<?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: Build groups on two conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Build-groups-on-two-conditions/m-p/934308#M367400</link>
    <description>Nice, thanks!</description>
    <pubDate>Mon, 01 Jul 2024 17:35:26 GMT</pubDate>
    <dc:creator>Preguntarius</dc:creator>
    <dc:date>2024-07-01T17:35:26Z</dc:date>
    <item>
      <title>Build groups on two conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-groups-on-two-conditions/m-p/934265#M367393</link>
      <description>&lt;P&gt;Hi everyone, I have a SAS table with the variable "target" which has only two possible values: 0 and 1.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Preguntarius_0-1719843874183.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98043i6B5D8FA2E42CCFA3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Preguntarius_0-1719843874183.png" alt="Preguntarius_0-1719843874183.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to build groups, starting from the first line, so that each group has at least 30 values 1 of "target" and so that each group has at least 2000 rows.&lt;/P&gt;&lt;P&gt;So, if f.e. in the first 2000 rows I already have 30 values 1 of "target", the first 2000 rows would build the first group. If not, I have to take more rows in the first group. And so on.&lt;/P&gt;&lt;P&gt;Does anybody has an Idea how to do it?&lt;/P&gt;&lt;P&gt;Thanks in Advance&lt;/P&gt;&lt;P&gt;Denis&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 14:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-groups-on-two-conditions/m-p/934265#M367393</guid>
      <dc:creator>Preguntarius</dc:creator>
      <dc:date>2024-07-01T14:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Build groups on two conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-groups-on-two-conditions/m-p/934284#M367397</link>
      <description>&lt;P&gt;Something like this ought to work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;&lt;BR /&gt;   group = _n_;&lt;BR /&gt;   n_targets = 0;&lt;BR /&gt;   group_size = 0;&lt;BR /&gt;   do until (group_size &amp;gt;= 2000 and n_targets &amp;gt;= 30);
      set have;
      group_size + 1;
      n_targets + target;&lt;BR /&gt;      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's untested, but you have the data to try it out.&amp;nbsp; As you might suspect, the last group might be a little smaller and you will need to figure out what to do with that.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 16:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-groups-on-two-conditions/m-p/934284#M367397</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-07-01T16:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Build groups on two conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-groups-on-two-conditions/m-p/934308#M367400</link>
      <description>Nice, thanks!</description>
      <pubDate>Mon, 01 Jul 2024 17:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-groups-on-two-conditions/m-p/934308#M367400</guid>
      <dc:creator>Preguntarius</dc:creator>
      <dc:date>2024-07-01T17:35:26Z</dc:date>
    </item>
  </channel>
</rss>

