<?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: how to create a dynamic datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493109#M129704</link>
    <description>&lt;P&gt;All you need to do is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;change&lt;/P&gt;
&lt;P&gt;data year_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro test;&lt;BR /&gt;%do i=&amp;amp;yr1 %to &amp;amp;&amp;amp;yr&amp;amp;cnt;&lt;BR /&gt;&lt;STRONG&gt;data year_&amp;amp;i; /*change here*/&lt;/STRONG&gt;&lt;BR /&gt;set one;&lt;BR /&gt;where year =&amp;amp;i;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend test;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Sep 2018 16:46:43 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-06T16:46:43Z</dc:date>
    <item>
      <title>how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493066#M129693</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can any one help me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a datasets name called one ,and variable is year.Based on variable year i have to create a dynamic dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input year ;&lt;BR /&gt;cards;&lt;BR /&gt;2015&lt;BR /&gt;2015&lt;BR /&gt;2016&lt;BR /&gt;2017&lt;BR /&gt;2018&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;select count(distinct year) into:cnt&lt;BR /&gt;from one;&lt;BR /&gt;quit;&lt;BR /&gt;proc sql;&lt;BR /&gt;select distinct year into :yr1-:%sysfunc(compress(yr&amp;amp;cnt.))&lt;BR /&gt;from one;&lt;BR /&gt;quit;&lt;BR /&gt;options symbolgen mprint mlogic;&lt;BR /&gt;%macro test;&lt;BR /&gt;%do i=1 %to &amp;amp;cnt;&lt;BR /&gt;data year_&amp;amp;i;&lt;BR /&gt;set one;&lt;BR /&gt;where year =&amp;amp;&amp;amp;yr&amp;amp;i;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend test;&lt;BR /&gt;%test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am getting output as work.year1&lt;/P&gt;&lt;P&gt;work.year2&lt;/P&gt;&lt;P&gt;work.year3&lt;/P&gt;&lt;P&gt;work.year4&lt;/P&gt;&lt;P&gt;instead of year1 and year2&lt;/P&gt;&lt;P&gt;i want work.2015&lt;/P&gt;&lt;P&gt;work.2016&lt;/P&gt;&lt;P&gt;work.2017&lt;/P&gt;&lt;P&gt;pls help me&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 15:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493066#M129693</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-09-06T15:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493069#M129696</link>
      <description>&lt;P&gt;First off, its not a good idea to split same data - that is an Excel way of thinking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do:&lt;/P&gt;
&lt;PRE&gt;proc sort data=one out=loop nodupkey;
  by year;
run;

data _null_;
  set loop;
  call execute(cats('data year',put(year,4.),'; set one; where year=',put(year,4.),'; run;'));
run;&lt;/PRE&gt;
&lt;P&gt;This will create one datastep for each unique year in dataset one.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 15:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493069#M129696</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-06T15:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493094#M129701</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input year ;
cards;
2015
2015
2016
2017
2018
;
run;
proc sql;
select count(distinct year) into:cnt trimmed
from one;
quit;
proc sql;
select distinct year into :yr1- trimmed
from one;
quit;

%put &amp;amp;yr4;
options nosymbolgen nomprint nomlogic;
%macro test;
%do i=&amp;amp;yr1 %to &amp;amp;&amp;amp;yr&amp;amp;cnt;
data year_&amp;amp;i;
set one;
where year =&amp;amp;i;
run;
%end;
%mend test;
%test;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I prefer&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;'s call execute approach and like he said it is not a great idea to split or sometimes I fancy using hashes but that's not really in scope for this trivial problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 16:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493094#M129701</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-06T16:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493098#M129702</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your support&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am getting output as&amp;nbsp;&lt;/P&gt;&lt;P&gt;year2015&lt;/P&gt;&lt;P&gt;year2016&lt;/P&gt;&lt;P&gt;year2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to get output as&amp;nbsp;&lt;/P&gt;&lt;P&gt;data_2015&lt;/P&gt;&lt;P&gt;data_2016&lt;/P&gt;&lt;P&gt;data_2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;will u pls support me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 16:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493098#M129702</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-09-06T16:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493104#M129703</link>
      <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your support&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i am getting output as&lt;BR /&gt;&lt;BR /&gt;year2015&lt;BR /&gt;&lt;BR /&gt;year2016&lt;BR /&gt;&lt;BR /&gt;year2017&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i want to get output as&lt;BR /&gt;&lt;BR /&gt;data_2015&lt;BR /&gt;&lt;BR /&gt;data_2016&lt;BR /&gt;&lt;BR /&gt;data_2017&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;will u pls support me&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Sep 2018 16:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493104#M129703</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-09-06T16:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493109#M129704</link>
      <description>&lt;P&gt;All you need to do is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;change&lt;/P&gt;
&lt;P&gt;data year_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro test;&lt;BR /&gt;%do i=&amp;amp;yr1 %to &amp;amp;&amp;amp;yr&amp;amp;cnt;&lt;BR /&gt;&lt;STRONG&gt;data year_&amp;amp;i; /*change here*/&lt;/STRONG&gt;&lt;BR /&gt;set one;&lt;BR /&gt;where year =&amp;amp;i;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend test;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 16:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493109#M129704</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-06T16:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493113#M129705</link>
      <description>&lt;P&gt;thanks yaar&lt;/P&gt;&lt;P&gt;one more small request&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the date is before 2018 years then show the date format as date9.&lt;/P&gt;&lt;P&gt;if the date is after than 2018 year then show the date format is ddmmyy10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pls suggest me yaar&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 16:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493113#M129705</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-09-06T16:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493114#M129706</link>
      <description>&lt;P&gt;I can't see any date values in your sample&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 17:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493114#M129706</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-06T17:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493115#M129707</link>
      <description>&lt;P&gt;sorry yaar i forget to mention date column in the sample code&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input date year;&lt;/P&gt;&lt;P&gt;format date date9.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;01jan2018 2018&lt;/P&gt;&lt;P&gt;02jan2017 2017&lt;/P&gt;&lt;P&gt;17dec2016 2016&lt;/P&gt;&lt;P&gt;25feb2014 2014&lt;/P&gt;&lt;P&gt;02feb2015 2015&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;this is the sample code yaar&lt;/P&gt;&lt;P&gt;i want a date set year wise and if the date set is before previous year then date format should be mmddyy10.&lt;/P&gt;&lt;P&gt;if the date is current year then date format is date9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pls support thank for advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 17:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493115#M129707</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-09-06T17:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493299#M129757</link>
      <description>&lt;P&gt;So your not even going to be consistent within your own process flow?&amp;nbsp; How are you going to use this data further, creating masses of macro code to try to utilise this data.&amp;nbsp; It is really&amp;nbsp;&lt;STRONG&gt;not a good idea to split like data up&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set year;
  if year &amp;lt; year(today())-1 then 
    call execute(cats('data data_',put(date,mmddyy10.),'; set yourds; where year=',put(year,4.),'; run;'));
  else 
    call execute(cats('data data_',put(year,4.),'; set one; where year=',put(year,4.),'; run;'));
run;&lt;/PRE&gt;
&lt;P&gt;You really are however opening yourself up to world of pain though unless this is just for export - and then your merely passing that pain onto someone else.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 07:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493299#M129757</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-07T07:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493300#M129758</link>
      <description>&lt;P&gt;IMO, the macro approach is not so bad. But I would do it differently:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Year_data(year);
  data data_&amp;amp;year;
    set one;
    where year=&amp;amp;year;
    %if &amp;amp;year=%sysfunc(date(),year4.) %then
      format date date9.;
   %else 
      format date mmddyy10.;
      ;
  run;
%mend;

proc sql noprint;
  select distinct cats('%year_data(',year,')') into :macrocall separated by ';'
  from one;
quit;

&amp;amp;macrocall;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Sep 2018 08:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-dynamic-datasets/m-p/493300#M129758</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-09-07T08:03:46Z</dc:date>
    </item>
  </channel>
</rss>

