<?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 Splitting dataset into multiple datasets by Entity and Month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820715#M323977</link>
    <description>&lt;P&gt;I have a WORK library filled with datasets, within these datasets are data ENTITY_ID,&amp;nbsp; and MONTH.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each dataset in the WORK library (called UT_01-UT_78), I want to split the original datasets up into multiple datasets sorted by the same ENTITY_ID and MONTH.&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;PRE&gt;/* Original Dataset Called: UT_01 */&lt;BR /&gt;ENTITY_ID  MONTH&lt;BR /&gt;Jake       11JAN19&lt;BR /&gt;Bob        11DEC17&lt;BR /&gt;Jake       11NOV18&lt;BR /&gt;Jake       11JAN20&lt;BR /&gt;Bob        11DEC18&lt;BR /&gt;Jake       11NOV21&lt;BR /&gt;&lt;BR /&gt;/* Split up to new file called: Jake_JAN */&lt;BR /&gt;ENTITY_ID  MONTH&lt;BR /&gt;JAKE       11JAN19&lt;BR /&gt;JAKE       11JAN20&lt;BR /&gt;&lt;BR /&gt;/* Split up to new file called: Jake_NOV */&lt;BR /&gt;ENTITY_ID  MONTH&lt;BR /&gt;JAKE      11NOV18&lt;BR /&gt;JAKE      11NOV21&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* Split up to new file called: Bob_DEC */&lt;BR /&gt;ENTITY_ID MONTH&lt;BR /&gt;Bob       11DEC18&lt;BR /&gt;Bob       11DEC17&lt;/PRE&gt;&lt;P&gt;The reason I want to split up datasets is to be able to present them in a easier way when I export as an excel file.&lt;/P&gt;&lt;P&gt;I am a SAS beginner so detailed help is appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2022 15:34:03 GMT</pubDate>
    <dc:creator>stormblaster98</dc:creator>
    <dc:date>2022-06-28T15:34:03Z</dc:date>
    <item>
      <title>Splitting dataset into multiple datasets by Entity and Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820715#M323977</link>
      <description>&lt;P&gt;I have a WORK library filled with datasets, within these datasets are data ENTITY_ID,&amp;nbsp; and MONTH.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each dataset in the WORK library (called UT_01-UT_78), I want to split the original datasets up into multiple datasets sorted by the same ENTITY_ID and MONTH.&lt;/P&gt;&lt;P&gt;Here is an example:&lt;/P&gt;&lt;PRE&gt;/* Original Dataset Called: UT_01 */&lt;BR /&gt;ENTITY_ID  MONTH&lt;BR /&gt;Jake       11JAN19&lt;BR /&gt;Bob        11DEC17&lt;BR /&gt;Jake       11NOV18&lt;BR /&gt;Jake       11JAN20&lt;BR /&gt;Bob        11DEC18&lt;BR /&gt;Jake       11NOV21&lt;BR /&gt;&lt;BR /&gt;/* Split up to new file called: Jake_JAN */&lt;BR /&gt;ENTITY_ID  MONTH&lt;BR /&gt;JAKE       11JAN19&lt;BR /&gt;JAKE       11JAN20&lt;BR /&gt;&lt;BR /&gt;/* Split up to new file called: Jake_NOV */&lt;BR /&gt;ENTITY_ID  MONTH&lt;BR /&gt;JAKE      11NOV18&lt;BR /&gt;JAKE      11NOV21&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* Split up to new file called: Bob_DEC */&lt;BR /&gt;ENTITY_ID MONTH&lt;BR /&gt;Bob       11DEC18&lt;BR /&gt;Bob       11DEC17&lt;/PRE&gt;&lt;P&gt;The reason I want to split up datasets is to be able to present them in a easier way when I export as an excel file.&lt;/P&gt;&lt;P&gt;I am a SAS beginner so detailed help is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 15:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820715#M323977</guid>
      <dc:creator>stormblaster98</dc:creator>
      <dc:date>2022-06-28T15:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting dataset into multiple datasets by Entity and Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820716#M323978</link>
      <description>&lt;P&gt;Why is this necessary? If you export one great big large Excel file, the user can then use the Filter in Excel to obtain Bob December records. Seems to me to be the easiest solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But anyway, this question how to split up large data sets in SAS gets asked probably once a week and a search of this community ought to find lots of examples with code.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 15:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820716#M323978</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-28T15:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting dataset into multiple datasets by Entity and Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820718#M323980</link>
      <description>&lt;P&gt;There are many tables that must be split with multiple entities and months in each so having it automated before exporting to excel is far better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I've been reading those however I am stuck on how to sort by ENTITY_ID and MONTH. I am also stuck on how I can split each dataset in the WORK library, right now I am only able to split 1 dataset at a time.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 15:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820718#M323980</guid>
      <dc:creator>stormblaster98</dc:creator>
      <dc:date>2022-06-28T15:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting dataset into multiple datasets by Entity and Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820723#M323985</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/428563"&gt;@stormblaster98&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There are many tables that must be split with multiple entities and months in each so having it automated before exporting to excel is far better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes I've been reading those however I am stuck on how to sort by ENTITY_ID and MONTH. I am also stuck on how I can split each dataset in the WORK library, right now I am only able to split 1 dataset at a time.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why do you have a problem sorting? Probably because your data is missing an important element. You currently apparently have a date value. If you want to sort by MONTH, not your date, then add a variable that actually contains the month and sort by that variable instead of your date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the purpose is to export to a spreadsheet then use ODS Excel for output and use something with the entity_id and actual month variables as BY with proc print.&lt;/P&gt;
&lt;P&gt;Maybe something like this which will send each entity_id month combination to a separate sheet in an Excel file.&lt;/P&gt;
&lt;P&gt;Note that using MONTH numbers allows sorts to work where MONTH names do no.&lt;/P&gt;
&lt;PRE&gt;data need;
   set ut_01;
   Monthnum = month(month);
run;

proc sort data=need;
   by entity_id monthnum;
run;

ods excel file="&amp;lt;your path&amp;gt;\yourfilename.xlsx"
options (sheet_interval='bygroup');

proc print data=need;
   by entity_id monthnum;
run;

ods excel close;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2022 16:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820723#M323985</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-28T16:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting dataset into multiple datasets by Entity and Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820724#M323986</link>
      <description>"There are many tables that must be split with multiple entities and months in each "&lt;BR /&gt;The questions remains, why is this needed?  "Must" they be split?  If there are multiple tables combine them, export one table and do the presentation level stuff in Excel as PaigeMiller suggests.  &lt;BR /&gt;&lt;BR /&gt;Perhaps if you provided more context or something.</description>
      <pubDate>Tue, 28 Jun 2022 16:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820724#M323986</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2022-06-28T16:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting dataset into multiple datasets by Entity and Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820735#M323994</link>
      <description>&lt;P&gt;I'll try to explain why it is needed. There are 78 tables, each of them have different data. I need to split up each table so that the excel file has more presentable sheets within it. It is not possible to combine each dataset into one big table since the data in each table is different.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Context: My current code creates 78 tables to the WORK library. The goal is to split all of these tables (where necessary) by ID and Month (as shown in my example of the original post) and then export it to an excel file to make it more presentable. So within that excel file will be each original dataset split up by ID and Month (UT_06, UT_06_Jake_DEC, UT_06_Jake_NOV, UT_06_Bob_OCT,...,UT_78, UT_78_Paul_JAN, etc.).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example of 2 datasets:&lt;/P&gt;&lt;PRE&gt;/* UT_06 */&lt;BR /&gt;ENTITY_ID  MONTH    Origin  Speed&lt;BR /&gt;Jake       11JAN19  USA     100 KM/h&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;/* UT_07 */&lt;BR /&gt;QUOTE_ID   DT       GROUP  COST&lt;BR /&gt;Farm       11NOV19  Land   $100.00&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;/* These are rough examples of how the datasets are different */&lt;/PRE&gt;&lt;P&gt;Sorry if Im not explaining it well, I hope this helped a little&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 16:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820735#M323994</guid>
      <dc:creator>stormblaster98</dc:creator>
      <dc:date>2022-06-28T16:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting dataset into multiple datasets by Entity and Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820743#M323997</link>
      <description>&lt;P&gt;So 78 splits ... the user then has to find the one they want, let's say John August. in that list of 78 ... or the user could have one Excel file and filter in Excel for John &amp;amp; August&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Roughly equal in amount of effort for the end user, in my opinion&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tomato ... tomahhto&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But lots more effort for the programmer.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 17:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-dataset-into-multiple-datasets-by-Entity-and-Month/m-p/820743#M323997</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-28T17:41:50Z</dc:date>
    </item>
  </channel>
</rss>

