<?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 append the data every 3 days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577619#M163684</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My query is how append every 3 days like&lt;BR /&gt;1st day:&lt;BR /&gt;Ex_28.&lt;BR /&gt;&lt;BR /&gt;2nd day:&lt;BR /&gt;Append. Ex_28 Ex_29&lt;BR /&gt;&lt;BR /&gt;3rd day:&lt;BR /&gt;Append Ex_28 Ex_29 Ex_30&lt;BR /&gt;&lt;BR /&gt;4th day:&lt;BR /&gt;Append Ex_29 Ex_30 Ex_31&lt;BR /&gt;On 4th day we have to avoid first day data set&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You say append.&amp;nbsp; Do you mean concatenate instead?&amp;nbsp; If you're appending, wouldn't you just append to the base table each day?&amp;nbsp; Or are you wanting a rolling three days?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I started with this, but I'm bailing out.&amp;nbsp; I don't know exactly what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* create some dummy datasets ;
data dates;
   do date="01JUL2019"d to "31JUL2019"d;
      output;
   end;
   format date yymmddn8.;
run;

proc sql noprint;
   select date into :dates separated by " " from dates;
quit;

%macro code;
   data ex_&amp;amp;word;
      chr_date="&amp;amp;word";  * dummy data ;
   run;
%mend;
%loop(&amp;amp;dates)

* initialize audit log ;
data auditlog;
   length rundate startdate enddate 8;
   format rundate date9. startdate enddate yymmddn.;
   rundate     = today();
   startdate   = today();
   enddate     = today();
run;

proc sql;
   select
      intnx('day',max_enddate,1) as startdate format=yymmddn.
     ,intnx('day',max_enddate,3) as startdate format=yymmddn.
   into
      :startdate,:enddate
   from (
   select 
      max(enddate) as max_enddate
   from
      auditlog
   )
   ;
quit;

%put &amp;amp;=startdate &amp;amp;=enddate;&lt;BR /&gt;&lt;BR /&gt;*&amp;nbsp;loop&amp;nbsp;over&amp;nbsp;the&amp;nbsp;dates,&amp;nbsp;append&amp;nbsp;the&amp;nbsp;source&amp;nbsp;tables,&amp;nbsp;and&amp;nbsp;write&amp;nbsp;a&amp;nbsp;row&amp;nbsp;to&amp;nbsp;the&amp;nbsp;audit&amp;nbsp;log.&amp;nbsp;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You don't explain what logic determines 1st day, 2nd day, 3rd day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can run with this code and make something work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point I'm guessing at the details of what you want to do, and why you want to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps get a colleague to help you better ask your question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://github.com/scottbass/SAS/blob/master/Macro/loop.sas" target="_blank" rel="noopener"&gt;https://github.com/scottbass/SAS/blob/master/Macro/loop.sas&lt;/A&gt;&amp;nbsp;for the %loop macro.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2019 06:44:13 GMT</pubDate>
    <dc:creator>ScottBass</dc:creator>
    <dc:date>2019-07-30T06:44:13Z</dc:date>
    <item>
      <title>How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577306#M163591</link>
      <description>/*28jul*/&lt;BR /&gt;Data set name: ex_28&lt;BR /&gt;&lt;BR /&gt;/*29jul*/&lt;BR /&gt;Data set name: ex_29&lt;BR /&gt;&lt;BR /&gt;/*30jul*/&lt;BR /&gt;Data set name: ex_30&lt;BR /&gt;/*31jul*/&lt;BR /&gt;Data set name: ex_31&lt;BR /&gt;&lt;BR /&gt;My query is how append every 3 days like&lt;BR /&gt;1st day:&lt;BR /&gt;Ex_28.&lt;BR /&gt;&lt;BR /&gt;2nd day:&lt;BR /&gt;Append. Ex_28 Ex_29&lt;BR /&gt;&lt;BR /&gt;3rd day:&lt;BR /&gt;Append Ex_28 Ex_29 Ex_30&lt;BR /&gt;&lt;BR /&gt;4th day:&lt;BR /&gt;Append Ex_29 Ex_30 Ex_31&lt;BR /&gt;On 4th day we have to avoid first day data set</description>
      <pubDate>Mon, 29 Jul 2019 09:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577306#M163591</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-07-29T09:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577313#M163595</link>
      <description>&lt;P&gt;Days alone are not sufficient to cover your situation, since you can't correctly calculate the flowovers between months.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 10:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577313#M163595</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-29T10:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577320#M163599</link>
      <description>&lt;P&gt;How are the datasets named after day 4?&lt;/P&gt;
&lt;P&gt;Will the datasets, that aren't needed for appending any more, be deleted?&lt;/P&gt;
&lt;P&gt;Is there a variable in the datasets to identify the day of creation/import?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is almost always a bad idea to dates, years or such information in dataset names, processing data will be easier if such information is stored in variables.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 11:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577320#M163599</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-29T11:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577321#M163600</link>
      <description>Day 4:Ex_31&lt;BR /&gt;Day 5:Ex_1.........&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Jul 2019 11:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577321#M163600</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-07-29T11:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577326#M163602</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Day 4:Ex_31&lt;BR /&gt;Day 5:Ex_1.........&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And from where do you know that the previous month had 31 days without knowing the exact month?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 11:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577326#M163602</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-29T11:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577329#M163603</link>
      <description>If all are 31 days months&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Jul 2019 12:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577329#M163603</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-07-29T12:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577336#M163605</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;If all are 31 days months&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Interesting concept ... you will have to give us some more examples, especially explaining what should happen when month changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 13:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577336#M163605</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-29T13:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577337#M163606</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;If all are 31 days months&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which calendar are you using? Mine has several months with 30 days, and one with 28&amp;nbsp;&lt;EM&gt;or&lt;/EM&gt; 29 ...&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 13:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577337#M163606</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-29T13:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577608#M163677</link>
      <description>&lt;P&gt;Is there any way you can rename your datasets from this poorly designed naming convention to ex_yyyymmdd, for example ex_20190730, ex_20190731, ex_20190801, ...., ex_20200101, etc.?&amp;nbsp; It will make your life much easier.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577608#M163677</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-07-30T06:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577610#M163678</link>
      <description>No problem datasets may like that also like you mentioned&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jul 2019 05:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577610#M163678</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-07-30T05:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577616#M163682</link>
      <description>&lt;P&gt;Since you haven't been forthcoming with requested details, I can only give you code to compute the dataset names for three days past:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length ds_string $100;
do date = today() - 2 to today();
  ds_string = catx(' ',ds_string,'ex_' !! put(date,yymmddn8.));
end;
call symputx('ds_string',ds_string);
run;

data want;
set &amp;amp;ds_string.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577616#M163682</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-30T06:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577619#M163684</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My query is how append every 3 days like&lt;BR /&gt;1st day:&lt;BR /&gt;Ex_28.&lt;BR /&gt;&lt;BR /&gt;2nd day:&lt;BR /&gt;Append. Ex_28 Ex_29&lt;BR /&gt;&lt;BR /&gt;3rd day:&lt;BR /&gt;Append Ex_28 Ex_29 Ex_30&lt;BR /&gt;&lt;BR /&gt;4th day:&lt;BR /&gt;Append Ex_29 Ex_30 Ex_31&lt;BR /&gt;On 4th day we have to avoid first day data set&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You say append.&amp;nbsp; Do you mean concatenate instead?&amp;nbsp; If you're appending, wouldn't you just append to the base table each day?&amp;nbsp; Or are you wanting a rolling three days?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I started with this, but I'm bailing out.&amp;nbsp; I don't know exactly what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* create some dummy datasets ;
data dates;
   do date="01JUL2019"d to "31JUL2019"d;
      output;
   end;
   format date yymmddn8.;
run;

proc sql noprint;
   select date into :dates separated by " " from dates;
quit;

%macro code;
   data ex_&amp;amp;word;
      chr_date="&amp;amp;word";  * dummy data ;
   run;
%mend;
%loop(&amp;amp;dates)

* initialize audit log ;
data auditlog;
   length rundate startdate enddate 8;
   format rundate date9. startdate enddate yymmddn.;
   rundate     = today();
   startdate   = today();
   enddate     = today();
run;

proc sql;
   select
      intnx('day',max_enddate,1) as startdate format=yymmddn.
     ,intnx('day',max_enddate,3) as startdate format=yymmddn.
   into
      :startdate,:enddate
   from (
   select 
      max(enddate) as max_enddate
   from
      auditlog
   )
   ;
quit;

%put &amp;amp;=startdate &amp;amp;=enddate;&lt;BR /&gt;&lt;BR /&gt;*&amp;nbsp;loop&amp;nbsp;over&amp;nbsp;the&amp;nbsp;dates,&amp;nbsp;append&amp;nbsp;the&amp;nbsp;source&amp;nbsp;tables,&amp;nbsp;and&amp;nbsp;write&amp;nbsp;a&amp;nbsp;row&amp;nbsp;to&amp;nbsp;the&amp;nbsp;audit&amp;nbsp;log.&amp;nbsp;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You don't explain what logic determines 1st day, 2nd day, 3rd day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can run with this code and make something work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point I'm guessing at the details of what you want to do, and why you want to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps get a colleague to help you better ask your question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://github.com/scottbass/SAS/blob/master/Macro/loop.sas" target="_blank" rel="noopener"&gt;https://github.com/scottbass/SAS/blob/master/Macro/loop.sas&lt;/A&gt;&amp;nbsp;for the %loop macro.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577619#M163684</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-07-30T06:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577620#M163685</link>
      <description>Thanq it's working&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577620#M163685</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-07-30T06:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to append the data every 3 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577935#M163835</link>
      <description>&lt;P&gt;Your original requirements:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;My query is how append every 3 days like&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1st day:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ex_28.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2nd day:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Append. Ex_28 Ex_29&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3rd day:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Append Ex_28 Ex_29 Ex_30&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4th day:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Append Ex_29 Ex_30 Ex_31&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On 4th day we have to avoid first day data set&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length ds_string $100;
do date = today() - 2 to today();
  ds_string = catx(' ',ds_string,'ex_' !! put(date,yymmddn8.));
end;
call symputx('ds_string',ds_string);
run;

data want;
set &amp;amp;ds_string.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Thanq it's working&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How is this "working"?&amp;nbsp; Your requirements were to return one dataset on day 1, two datasets on day 2, 3 datasets on day 3, then a rolling 3 datasets backwards from day 4 onward.&amp;nbsp; The solution doesn't do that.&amp;nbsp; And you say that you only append every three days, not every day per the solution.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You need to learn to ask a better question if you expect a better answer (and in less than two pages and 13 posts).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 01:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-the-data-every-3-days/m-p/577935#M163835</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-07-31T01:49:02Z</dc:date>
    </item>
  </channel>
</rss>

