<?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: Split table into multiple tables with specific count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916038#M360890</link>
    <description>&lt;P&gt;Splitting tables is rarely necessary. You can leave this as one big table, with an identifier variable to indicate which of the four parts, then perform analyses BY this identifier variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars;
    set sashelp.cars;
    if mod(_n_,25)=1 then identifier+1;
run;

proc means data=cars;
    by identifier;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If, for example, you only want to work on the data when identifier=3 (and not the rest of the data), you can do this too&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=cars;
    where identifier=3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Feb 2024 11:55:00 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-02-14T11:55:00Z</dc:date>
    <item>
      <title>Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916035#M360889</link>
      <description>Hello! How do I split one table into multiple tables and limit the number of observations to 25 for each table? Then I need to export all tables in excel. &lt;BR /&gt;Ex. I have a table with 99 obs and I need to split it to 4 tables with the first 3 tables having 25 obs and the last having 24. The original table can have different number of obs.</description>
      <pubDate>Wed, 14 Feb 2024 10:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916035#M360889</guid>
      <dc:creator>JT99</dc:creator>
      <dc:date>2024-02-14T10:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916038#M360890</link>
      <description>&lt;P&gt;Splitting tables is rarely necessary. You can leave this as one big table, with an identifier variable to indicate which of the four parts, then perform analyses BY this identifier variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cars;
    set sashelp.cars;
    if mod(_n_,25)=1 then identifier+1;
run;

proc means data=cars;
    by identifier;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If, for example, you only want to work on the data when identifier=3 (and not the rest of the data), you can do this too&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=cars;
    where identifier=3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 11:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916038#M360890</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-14T11:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916042#M360892</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let size = 25;

data want;
set have;
retain group 1;
if mod(_n_,&amp;amp;size.) = 0 then group + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You now have a group designator which can be used in multiple ways, e.g. to switch sheets when using ODS EXCEL and a reporting procedure.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 12:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916042#M360892</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-02-14T12:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916199#M360915</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let size = 25;

data want;
set have;
retain group 1;
if mod(_n_,&amp;amp;size.) = 0 then group + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You now have a group designator which can be used in multiple ways, e.g. to switch sheets when using ODS EXCEL and a reporting procedure.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I agree with your comment.&amp;nbsp; But the code needs a minor tweak.&amp;nbsp; The first group above would only have 24 observations.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 21:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916199#M360915</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-02-14T21:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916204#M360917</link>
      <description>&lt;P&gt;I think this will do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;retain group 0;
if mod(_n_ - 1,&amp;amp;size.) = 0 then group + 1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Feb 2024 21:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916204#M360917</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-02-14T21:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916217#M360919</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think this will do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;retain group 0;
if mod(_n_ - 1,&amp;amp;size.) = 0 then group + 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Or my code earlier will do it as well.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 23:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916217#M360919</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-14T23:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916218#M360920</link>
      <description>Thank you all so much! Your replies are a big help.</description>
      <pubDate>Wed, 14 Feb 2024 23:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916218#M360920</guid>
      <dc:creator>JT99</dc:creator>
      <dc:date>2024-02-14T23:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916219#M360921</link>
      <description>&lt;P&gt;Wrote a macro for this a while back:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/49e54641ceaf58bc4fe5dc2062bc89cb" target="_blank"&gt;https://gist.github.com/statgeek/49e54641ceaf58bc4fe5dc2062bc89cb&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 23:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916219#M360921</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-14T23:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Split table into multiple tables with specific count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916220#M360922</link>
      <description>Perfect! Thank you!</description>
      <pubDate>Thu, 15 Feb 2024 00:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-table-into-multiple-tables-with-specific-count/m-p/916220#M360922</guid>
      <dc:creator>JT99</dc:creator>
      <dc:date>2024-02-15T00:06:16Z</dc:date>
    </item>
  </channel>
</rss>

