<?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: Dynamically concatinating datasets based on a date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286625#M58815</link>
    <description>&lt;PRE&gt;





data have;
input date date9.;
cards;
31Dec2015 
31mar2016
;
run;
data temp;
 set have;
 length list $ 400;
 do i=-1 to -9 by -1;
  list=catx(' ',list,'data_'||put(intnx('qtr',date,i),yyq.));
 end;
 data=catx('_','inp',put(intnx('qtr',date,-9),yyq.),put(date,yyq.));
 drop i;
run;

data _null_;
 set temp;
 call execute(catx(' ','data',data,';set',list,';run;'));
run;



&lt;/PRE&gt;</description>
    <pubDate>Sun, 24 Jul 2016 02:40:13 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-07-24T02:40:13Z</dc:date>
    <item>
      <title>Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286594#M58800</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a report date which is end of every qtr like 31Dec2015 and Using a variable created from report date ,I have 9 datasets like data_2015Q4, data_2015Q3.....data_2013Q3.Finally I want to append these 9 datasets to create a dataset like inp_2013q3_2015q4.but the issue is this should be done dynamically.For ex, in next qtr i,e 31mar2016, I need to append datasets going back 9 quarters i,e from 2014q1 to 2016q1. How do I do this?</description>
      <pubDate>Sat, 23 Jul 2016 17:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286594#M58800</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-07-23T17:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286616#M58810</link>
      <description>&lt;P&gt;I would change your process so that it appends the dataset to the 'master' dataset at the end of the process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatives are to store all the output with a consistent naming structure in a library.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use a prefix that isn't used with any other datsets you can refer to it with a colon to append all datasets with the same prefix.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ie this would append all datasets starting with IMP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set imp: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2016 01:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286616#M58810</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-24T01:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286625#M58815</link>
      <description>&lt;PRE&gt;





data have;
input date date9.;
cards;
31Dec2015 
31mar2016
;
run;
data temp;
 set have;
 length list $ 400;
 do i=-1 to -9 by -1;
  list=catx(' ',list,'data_'||put(intnx('qtr',date,i),yyq.));
 end;
 data=catx('_','inp',put(intnx('qtr',date,-9),yyq.),put(date,yyq.));
 drop i;
run;

data _null_;
 set temp;
 call execute(catx(' ','data',data,';set',list,';run;'));
run;



&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2016 02:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286625#M58815</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-24T02:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286627#M58817</link>
      <description>Thank u so much Ksharp &amp;amp; Reeza for ur reply. But the report date is an user input every quarter like % let enddate="31dec2015".Using these date, sas has to go 9 qtr back dynamically and append datasets in a library with a fixed naming structure like data_2015Q1,data_2014q4....Tge library might have more than 9 qtrs of data but it sud append till 9 qtrs back starting from enddate.&lt;BR /&gt;Appreciate ur help.</description>
      <pubDate>Sun, 24 Jul 2016 03:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286627#M58817</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-07-24T03:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286631#M58818</link>
      <description>&lt;PRE&gt;
Still the same thing :




%let date=31dec2015;


data temp;
 length list $ 400;
 do i=-1 to -9 by -1;
  list=catx(' ',list,'data_'||put(intnx('qtr',"&amp;amp;date"d,i),yyq.));
 end;
 data=catx('_','inp',put(intnx('qtr',"&amp;amp;date"d,-9),yyq.),put("&amp;amp;date"d,yyq.));
 drop i;
run;

data _null_;
 set temp;
 call execute(catx(' ','data',data,';set',list,';run;'));
run;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2016 03:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286631#M58818</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-24T03:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286633#M58819</link>
      <description>&lt;PRE&gt;
Still the same thing :


%let date=31dec2015;
data temp;
 length list $ 400;
 do i=-1 to -9 by -1;
  list=catx(' ',list,'data_'||put(intnx('qtr',"&amp;amp;date"d,i),yyq.));
 end;
 data=catx('_','inp',put(intnx('qtr',"&amp;amp;date"d,-9),yyq.),put("&amp;amp;date"d,yyq.));
 drop i;
run;

data _null_;
 set temp;
 call execute(catx(' ','data',data,';set',list,';run;'));
run;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2016 03:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286633#M58819</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-24T03:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286635#M58820</link>
      <description>&lt;P&gt;Get the dataset names from dictionary.tables and filter according to your requirements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data_2015Q4; x=1; run;
data data_2015Q3; x=2; run;
data data_2015Q2; x=3; run;
data data_2015Q1; x=4; run;
data data_2014Q4; x=5; run;
data data_2014Q3; x=6; run;
data data_2014Q2; x=7; run;
data data_2014Q1; x=8; run;
data data_2013Q4; x=9; run;
data data_2013Q3; x=10; run;
data data_2013Q2; x=11; run;
data data_2013Q1; x=12; run;

%let rptDate=31Dec2015;

proc sql noprint;
create table rptList as
select memname
from dictionary.tables
where libname="WORK" and
    memname like "DATA_____Q_" and
    intnx("QTR",input(scan(memname,2,"_"), ? yyq6.),0,"END") between
    intnx("QTR", "&amp;amp;rptDate"d, -8, "END") and
    "&amp;amp;rptDate"d;
select memname 
into:setList separated by " "
from rptList order by memname desc;
select catx("_", "inp", min(scan(memname,2,"_")), max(scan(memname,2,"_")))
into:setName trimmed
from rptList; 
drop table rptList, &amp;amp;setName;
quit;

data &amp;amp;setName;
set &amp;amp;setList;
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2016 03:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286635#M58820</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-24T03:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically concatinating datasets based on a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286651#M58828</link>
      <description>This is awesome. Thanks for ur help&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;</description>
      <pubDate>Sun, 24 Jul 2016 12:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-concatinating-datasets-based-on-a-date/m-p/286651#M58828</guid>
      <dc:creator>SM3</dc:creator>
      <dc:date>2016-07-24T12:19:47Z</dc:date>
    </item>
  </channel>
</rss>

