<?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: Repeating a sequence of dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846714#M334702</link>
    <description>&lt;P&gt;Why use a DO WHILE() when you are just iterating?&amp;nbsp; Why not just a normal&amp;nbsp; old regular DO loop?&lt;/P&gt;
&lt;P&gt;Add another loop to generate the 10 groups.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Dates;
  do group=1 to 10;
    do date="&amp;amp;start_date"d to "&amp;amp;end_date"d ;
      output;
    end;
  end;
  format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 23:52:39 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-28T23:52:39Z</dc:date>
    <item>
      <title>Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/806881#M317990</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; The current code generates 10 observations and 10 dates.&amp;nbsp;I would like to repeat this sequence of dates 10 times so that there will 100 observations and the dates should be in that order during the repetition. for example obs 1-10, 11-20, 21-30, etc will all have the same set of dates. Any&amp;nbsp; help would be appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let start_date=01Jan2008;
%let end_date=10Jan2008;

data Dates;
date="&amp;amp;start_date"d;
do while (date&amp;lt;="&amp;amp;end_date"d);
    output;
    date=intnx('day', date, 1, 's');
end;
format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-04-08 at 7.09.59 PM.png" style="width: 269px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70261i799B4C7FF81E76D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-04-08 at 7.09.59 PM.png" alt="Screen Shot 2022-04-08 at 7.09.59 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 23:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/806881#M317990</guid>
      <dc:creator>stevenyan0127</dc:creator>
      <dc:date>2022-04-08T23:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/807118#M318137</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/367709"&gt;@stevenyan0127&lt;/a&gt;&amp;nbsp;, is this what you're after?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dateGenerator(start,end,multi,out);

*define date range;
%let start_date=&amp;amp;start;
%let end_date=&amp;amp;end;

*generate list of dates;
data Dates;
date="&amp;amp;start_date"d;
do while (date&amp;lt;="&amp;amp;end_date"d);
    output;
    date=intnx('day', date, 1, 's');
end;
format date date9.;
run;

*initialise base table;
data dates_out;
set dates;
run;

*Set counter from desired multiplier;
%let counter=%SYSEVALF(&amp;amp;multi - 1);

*loop through multiplier adding dates table;
%do i=1 %to &amp;amp;counter;
data dates_out;
set dates_out dates;
run;
%end;

*create output table with rownumber;
data &amp;amp;out;
set dates_out;
rownum+1;
run;

%mend;

%dateGenerator(01Jan2008,10Jan2008,10,myDates);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've used your original code and effectively put it into a loop which multiplies the number of records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 09:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/807118#M318137</guid>
      <dc:creator>HarrySnart</dc:creator>
      <dc:date>2022-04-11T09:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/807123#M318139</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_date=01Jan2008;
%let end_date=10Jan2008;

data Dates;
date="&amp;amp;start_date"d;
count=0;
do while (date&amp;lt;="&amp;amp;end_date"d);
    count=count+1;
    do i=1 to 10;
         n=(i-1)*10+count;   
         output;
    end;
    date=date+1;
end;
format date date9.;
drop count i;
run;
proc sort data=dates;
    by n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2022 10:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/807123#M318139</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-11T10:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/807188#M318178</link>
      <description>&lt;P&gt;Nested DO loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start_date=01Jan2008;
%let end_date=10Jan2008;

data Dates;
do i = 1 to 10;
  do date = "&amp;amp;start_date."d to "&amp;amp;end_date."d;
    output;
  end;
end;
format date date9.;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since dates are counts of days, it is not necessary to use the INTNX function to increment daily. INTNX is mainly needed for larger, irregular intervals like months, quarters or years.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 16:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/807188#M318178</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-11T16:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846643#M334678</link>
      <description>Hi can you do this to repeat a year?</description>
      <pubDate>Mon, 28 Nov 2022 16:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846643#M334678</guid>
      <dc:creator>kris8</dc:creator>
      <dc:date>2022-11-28T16:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846647#M334680</link>
      <description>how would you do it for a year?&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Nov 2022 16:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846647#M334680</guid>
      <dc:creator>kris8</dc:creator>
      <dc:date>2022-11-28T16:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846709#M334700</link>
      <description>&lt;P&gt;Just set the start and end dates accordingly, and the loop will work through all 365 (or 366 in a leap year) days of the year.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 22:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846709#M334700</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-28T22:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Repeating a sequence of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846714#M334702</link>
      <description>&lt;P&gt;Why use a DO WHILE() when you are just iterating?&amp;nbsp; Why not just a normal&amp;nbsp; old regular DO loop?&lt;/P&gt;
&lt;P&gt;Add another loop to generate the 10 groups.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Dates;
  do group=1 to 10;
    do date="&amp;amp;start_date"d to "&amp;amp;end_date"d ;
      output;
    end;
  end;
  format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 23:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Repeating-a-sequence-of-dates/m-p/846714#M334702</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-28T23:52:39Z</dc:date>
    </item>
  </channel>
</rss>

