<?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: Macro to split dataset into 4 tables based on input table size in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-split-dataset-into-4-tables-based-on-input-table-size/m-p/638132#M189746</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320380"&gt;@PegaZeus&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to add a variant of Kurt Bremser's solution: W&lt;SPAN&gt;ith two modifications to&amp;nbsp;his&amp;nbsp;&lt;/SPAN&gt;code you can achieve a partition into four blocks of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;consecutive&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;observations of dataset HAVE (first, second, third and fourth quarter):&lt;/P&gt;
&lt;PRE&gt;set have &lt;FONT color="#00CCFF"&gt;&lt;STRONG&gt;nobs=n&lt;/STRONG&gt;&lt;/FONT&gt;;
select &lt;FONT color="#000000"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#00CCFF"&gt;int(4*(_n_-1)/n)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#00CCFF"&gt;&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;Edit: If you use this in a macro, you should name variable &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; differently, e.g. &lt;FONT face="courier new,courier"&gt;___n&lt;/FONT&gt;,&amp;nbsp; or dynamically in order to avoid name conflicts with a possibly existing variable &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; in dataset HAVE.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 16:53:22 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2020-04-07T16:53:22Z</dc:date>
    <item>
      <title>Macro to split dataset into 4 tables based on input table size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-split-dataset-into-4-tables-based-on-input-table-size/m-p/638120#M189744</link>
      <description>&lt;P&gt;I'm interested in developing a macro that can split a table into 4 datasets proportional to the size of the input table. Four tables with an equal (or roughly equal) number of records. So to create a macro that takes a table and breaks it up into 4 based on the size of the input table. So for a table with 100,000 records, I'd want it to break it into 4 tables with 25,000 records each.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 16:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-split-dataset-into-4-tables-based-on-input-table-size/m-p/638120#M189744</guid>
      <dc:creator>PegaZeus</dc:creator>
      <dc:date>2020-04-07T16:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to split dataset into 4 tables based on input table size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-split-dataset-into-4-tables-based-on-input-table-size/m-p/638123#M189745</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data
  want1
  want2
  want3
  want4
;
set have;
select (mod(_n_,4));
  when (0) output want1;
  when (1) output want2;
  when (2) output want3;
  when (3) output want4;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I guess it can be seen how this step can be made dynamic.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 16:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-split-dataset-into-4-tables-based-on-input-table-size/m-p/638123#M189745</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-07T16:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to split dataset into 4 tables based on input table size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-split-dataset-into-4-tables-based-on-input-table-size/m-p/638132#M189746</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/320380"&gt;@PegaZeus&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to add a variant of Kurt Bremser's solution: W&lt;SPAN&gt;ith two modifications to&amp;nbsp;his&amp;nbsp;&lt;/SPAN&gt;code you can achieve a partition into four blocks of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;consecutive&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;observations of dataset HAVE (first, second, third and fourth quarter):&lt;/P&gt;
&lt;PRE&gt;set have &lt;FONT color="#00CCFF"&gt;&lt;STRONG&gt;nobs=n&lt;/STRONG&gt;&lt;/FONT&gt;;
select &lt;FONT color="#000000"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#00CCFF"&gt;int(4*(_n_-1)/n)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#00CCFF"&gt;&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;Edit: If you use this in a macro, you should name variable &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; differently, e.g. &lt;FONT face="courier new,courier"&gt;___n&lt;/FONT&gt;,&amp;nbsp; or dynamically in order to avoid name conflicts with a possibly existing variable &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; in dataset HAVE.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 16:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-split-dataset-into-4-tables-based-on-input-table-size/m-p/638132#M189746</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-04-07T16:53:22Z</dc:date>
    </item>
  </channel>
</rss>

