<?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: Create multiple dataset from one original dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489028#M127551</link>
    <description>&lt;P&gt;There really isn't a good reason to do this, it usually only needed when you'll run out of memory or because you're absolutely required to analyze it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since people rarely listen to this advice:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I create multiple data sets from one original dataset by following codes,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-sas"&gt;DATA step1.year1991 
     step1.year1992 
     step1.year1993 
     step1.year1994 
     step1.year1995 
     step1.year1996 
     step1.year1997 
     step1.year1998 
     step1.year1999 
     step1.year2000 
     step1.year2001 
     step1.year2002 
     step1.year2003 
     step1.year2004 
     step1.year2005 
     step1.year2006;
   SET old-data-set;
   IF earliest_filing_date = 1991 THAN output step1.year1991;
   ELSE IF earliest_filing_date = 1992 THAN output step1.year1992;
   ELSE IF earliest_filing_date = 1993 THAN output step1.year1993;
   ELSE IF earliest_filing_date = 1994 THAN output step1.year1994;
   ELSE IF earliest_filing_date = 1995 THAN output step1.year1995;
   ELSE IF earliest_filing_date = 1996 THAN output step1.year1996;
   ELSE IF earliest_filing_date = 1997 THAN output step1.year1997;
   ELSE IF earliest_filing_date = 1998 THAN output step1.year1998;
   ELSE IF earliest_filing_date = 1999 THAN output step1.year1999;
   ELSE IF earliest_filing_date = 2000 THAN output step1.year2000;
   ELSE IF earliest_filing_date = 2001 THAN output step1.year2001;
   ELSE IF earliest_filing_date = 2002 THAN output step1.year2002;
   ELSE IF earliest_filing_date = 2003 THAN output step1.year2003;
   ELSE IF earliest_filing_date = 2004 THAN output step1.year2004;
   ELSE IF earliest_filing_date = 2005 THAN output step1.year2005;
   ELSE IF earliest_filing_date = 2006 THAN output step1.year2006;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please give me some suggestion to improve these codes if I do not want to copy the similar codes so many times?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;many thanks in advance,&lt;/P&gt;
&lt;P&gt;best regards,&lt;/P&gt;
&lt;P&gt;France&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 20:02:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-08-22T20:02:17Z</dc:date>
    <item>
      <title>Create multiple dataset from one original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489026#M127550</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create multiple data sets from one original dataset by following codes,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-sas"&gt;DATA step1.year1991 
     step1.year1992 
     step1.year1993 
     step1.year1994 
     step1.year1995 
     step1.year1996 
     step1.year1997 
     step1.year1998 
     step1.year1999 
     step1.year2000 
     step1.year2001 
     step1.year2002 
     step1.year2003 
     step1.year2004 
     step1.year2005 
     step1.year2006;
   SET old-data-set;
   IF earliest_filing_date = 1991 THAN output step1.year1991;
   ELSE IF earliest_filing_date = 1992 THAN output step1.year1992;
   ELSE IF earliest_filing_date = 1993 THAN output step1.year1993;
   ELSE IF earliest_filing_date = 1994 THAN output step1.year1994;
   ELSE IF earliest_filing_date = 1995 THAN output step1.year1995;
   ELSE IF earliest_filing_date = 1996 THAN output step1.year1996;
   ELSE IF earliest_filing_date = 1997 THAN output step1.year1997;
   ELSE IF earliest_filing_date = 1998 THAN output step1.year1998;
   ELSE IF earliest_filing_date = 1999 THAN output step1.year1999;
   ELSE IF earliest_filing_date = 2000 THAN output step1.year2000;
   ELSE IF earliest_filing_date = 2001 THAN output step1.year2001;
   ELSE IF earliest_filing_date = 2002 THAN output step1.year2002;
   ELSE IF earliest_filing_date = 2003 THAN output step1.year2003;
   ELSE IF earliest_filing_date = 2004 THAN output step1.year2004;
   ELSE IF earliest_filing_date = 2005 THAN output step1.year2005;
   ELSE IF earliest_filing_date = 2006 THAN output step1.year2006;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please give me some suggestion to improve these codes if I do not want to copy the similar codes so many times?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many thanks in advance,&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;France&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 19:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489026#M127550</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-08-22T19:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple dataset from one original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489028#M127551</link>
      <description>&lt;P&gt;There really isn't a good reason to do this, it usually only needed when you'll run out of memory or because you're absolutely required to analyze it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since people rarely listen to this advice:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I create multiple data sets from one original dataset by following codes,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-sas"&gt;DATA step1.year1991 
     step1.year1992 
     step1.year1993 
     step1.year1994 
     step1.year1995 
     step1.year1996 
     step1.year1997 
     step1.year1998 
     step1.year1999 
     step1.year2000 
     step1.year2001 
     step1.year2002 
     step1.year2003 
     step1.year2004 
     step1.year2005 
     step1.year2006;
   SET old-data-set;
   IF earliest_filing_date = 1991 THAN output step1.year1991;
   ELSE IF earliest_filing_date = 1992 THAN output step1.year1992;
   ELSE IF earliest_filing_date = 1993 THAN output step1.year1993;
   ELSE IF earliest_filing_date = 1994 THAN output step1.year1994;
   ELSE IF earliest_filing_date = 1995 THAN output step1.year1995;
   ELSE IF earliest_filing_date = 1996 THAN output step1.year1996;
   ELSE IF earliest_filing_date = 1997 THAN output step1.year1997;
   ELSE IF earliest_filing_date = 1998 THAN output step1.year1998;
   ELSE IF earliest_filing_date = 1999 THAN output step1.year1999;
   ELSE IF earliest_filing_date = 2000 THAN output step1.year2000;
   ELSE IF earliest_filing_date = 2001 THAN output step1.year2001;
   ELSE IF earliest_filing_date = 2002 THAN output step1.year2002;
   ELSE IF earliest_filing_date = 2003 THAN output step1.year2003;
   ELSE IF earliest_filing_date = 2004 THAN output step1.year2004;
   ELSE IF earliest_filing_date = 2005 THAN output step1.year2005;
   ELSE IF earliest_filing_date = 2006 THAN output step1.year2006;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please give me some suggestion to improve these codes if I do not want to copy the similar codes so many times?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;many thanks in advance,&lt;/P&gt;
&lt;P&gt;best regards,&lt;/P&gt;
&lt;P&gt;France&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 20:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489028#M127551</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T20:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple dataset from one original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489031#M127553</link>
      <description>&lt;P&gt;As Reeza mentioned, in all likelihood there isn't a good reason to do this.&amp;nbsp; But if you really must, you can use macro language.&amp;nbsp; It won't shorten the code, but it will shorten the tedium of having to type it out.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro multiple_years;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%local k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;data&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%do k=1991 %to 2006;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; step1.year&amp;amp;k&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set old_data_set;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if earliest_filing_date=1991 then output step1.year1991;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%do k=1992 %to 2006;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else if earliest_filing_date=&amp;amp;k then output step1.year&amp;amp;k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend multiple_years;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%multiple_years&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 20:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489031#M127553</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-22T20:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create multiple dataset from one original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489038#M127560</link>
      <description>Dear Reeza,&lt;BR /&gt;many thanks for your help.</description>
      <pubDate>Wed, 22 Aug 2018 20:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-multiple-dataset-from-one-original-dataset/m-p/489038#M127560</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-08-22T20:21:20Z</dc:date>
    </item>
  </channel>
</rss>

