<?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 several tables by year from one original table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501506#M133713</link>
    <description>&lt;P&gt;Construct multiple IF conditions into a macro&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
Input year information :$;
datalines;
2015 x
2016 y
2015 z
2014 x
;
run;

option symbolgen mprint mlogic;
proc sql noprint;
select distinct "if year="||put(year,4.)||" then output "||cats("test",year), cats("test",year)
			Into: if_condition separated by " ;", :ds_list separated by " "
from have;
quit;

%put "&amp;amp;if_condition" ;
%put &amp;amp;ds_list;


data &amp;amp;ds_list;
set have;
&amp;amp;if_condition;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Oct 2018 14:38:03 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-10-04T14:38:03Z</dc:date>
    <item>
      <title>Create several tables by year from one original table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501494#M133709</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think its an easy task for you, but obviously not for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have one original table looks like that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; information&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;2016&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z&lt;/P&gt;&lt;P&gt;2014&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want to do is to create three tables named test2014, test2015, test2016 including only the information related to the named year:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test2014:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; information&lt;/P&gt;&lt;P&gt;2014&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test2015:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; information&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; z&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test2016:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; information&lt;/P&gt;&lt;P&gt;2016&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried something like this.&lt;/P&gt;&lt;P&gt;year=&amp;amp;year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Test&amp;amp;year;&lt;BR /&gt;set originaldata;&lt;BR /&gt;DO year=2014 to 2016;&lt;BR /&gt;where year=&amp;amp;year;&lt;BR /&gt;end:&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i think there is some basic macro/loop knowledge missing &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your effort!&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 14:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501494#M133709</guid>
      <dc:creator>Dynamike</dc:creator>
      <dc:date>2018-10-04T14:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create several tables by year from one original table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501496#M133710</link>
      <description>&lt;P&gt;The simple answer is don't.&amp;nbsp; There are very few, if any reasons, for splitting like data up into different datasets, and the outcome of doing so is increased storage space, more complex coding which is less robust.&lt;/P&gt;
&lt;P&gt;If you need to create a report or do some processing on the data by year, which may be why your asking, then use the inbuilt by group processing system:&lt;/P&gt;
&lt;PRE&gt;proc report...;
  by year;
...
&lt;/PRE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;proc means....
  by year;
...&lt;/PRE&gt;
&lt;P&gt;Its quicker than any other method.&lt;/P&gt;
&lt;P&gt;As for the theoretical how to do it, which you wouldn't be doing because that is suboptimal:&lt;/P&gt;
&lt;PRE&gt;proc sort data=have out=loop nodupkey;
  by year;
run;
data _null_;
  set loop;
  call execute(cats('data test',put(year,z4.),'; set have; where year=',put(year,z4.),';run;'));
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 14:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501496#M133710</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-04T14:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create several tables by year from one original table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501500#M133711</link>
      <description>&lt;P&gt;this is priceless advice. creating multiple datasets in your scenario can easily become maintenance nightmare, especially if you have to make changes.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 14:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501500#M133711</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-10-04T14:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create several tables by year from one original table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501502#M133712</link>
      <description>&lt;P&gt;These links has all that you need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Split_Data_into_Subsets" target="_blank"&gt;http://www.sascommunity.org/wiki/Split_Data_into_Subsets&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 14:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501502#M133712</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-04T14:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create several tables by year from one original table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501506#M133713</link>
      <description>&lt;P&gt;Construct multiple IF conditions into a macro&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
Input year information :$;
datalines;
2015 x
2016 y
2015 z
2014 x
;
run;

option symbolgen mprint mlogic;
proc sql noprint;
select distinct "if year="||put(year,4.)||" then output "||cats("test",year), cats("test",year)
			Into: if_condition separated by " ;", :ds_list separated by " "
from have;
quit;

%put "&amp;amp;if_condition" ;
%put &amp;amp;ds_list;


data &amp;amp;ds_list;
set have;
&amp;amp;if_condition;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 14:38:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-several-tables-by-year-from-one-original-table/m-p/501506#M133713</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-04T14:38:03Z</dc:date>
    </item>
  </channel>
</rss>

