<?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 table with increasing dates in loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-table-with-increasing-dates-in-loop/m-p/644066#M192327</link>
    <description>&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;It's exactly what I need!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank You very much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Apr 2020 20:07:35 GMT</pubDate>
    <dc:creator>Irena_ik</dc:creator>
    <dc:date>2020-04-29T20:07:35Z</dc:date>
    <item>
      <title>create table with increasing dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-with-increasing-dates-in-loop/m-p/644053#M192325</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Maybe someone can help me with my case, I have one &lt;EM&gt;obs date '20APR2020'&lt;/EM&gt;&amp;nbsp; in table &lt;EM&gt;week0&lt;/EM&gt; and i need to create one table with 7 obs, '20APR2020','21APR2020','22APR2020' etc.&lt;/P&gt;&lt;P&gt;i try this but i doesn't work correctly&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%macro sqlloop(start,end); &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;PROC SQL;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%DO i=&amp;amp;start. %TO &amp;amp;end.; &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;/* %let j=%eval(&amp;amp;i+1);*/&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CREATE TABLE week%eval(&amp;amp;i+1) as&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SELECT&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;intnx('day',day,&amp;amp;i.) as day format=date9.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;FROM week&amp;amp;i. ;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;/*union */&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;/*select * from ; */&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%END; &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;QUIT;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%mend;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%sqlloop(start=0, end=7)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need one table with values (for start I have only one date '20APR2020'):&lt;/P&gt;&lt;P&gt;'20APR2020'&lt;/P&gt;&lt;P&gt;'21APR2020'&lt;/P&gt;&lt;P&gt;'22APR2020'&lt;/P&gt;&lt;P&gt;'23APR2020'&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 19:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-with-increasing-dates-in-loop/m-p/644053#M192325</guid>
      <dc:creator>Irena_ik</dc:creator>
      <dc:date>2020-04-29T19:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: create table with increasing dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-with-increasing-dates-in-loop/m-p/644062#M192326</link>
      <description>&lt;P&gt;Are there any other variables involved? If so, what values should they have for the added rows?&lt;/P&gt;
&lt;P&gt;Is your "date" a character variable or a SAS date value with the date9 format assigned? It isn't really clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the &amp;lt;&amp;gt; to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Often the data step is much easier to do something like add additional records based on an incrementing rule.&lt;/P&gt;
&lt;P&gt;Below code shows creating 7 observation from scratch and adding 6 observations.&lt;/P&gt;
&lt;PRE&gt;data want;
  day='20APR2020'd;
  output;
  do i=1 to 6;
   day = intnx('day',day,1);
   output;
  end;
  format day date9.;
  drop i;
run;
/* IF you actually have a dataset named week0
  with a date valued variable named day:
*/

data want;
  set week0;
  output;
  do i=1 to 6;
   day = intnx('day',day,1);
   output;
  end;
  format day date9.;
  drop i;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 19:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-with-increasing-dates-in-loop/m-p/644062#M192326</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-29T19:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: create table with increasing dates in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-with-increasing-dates-in-loop/m-p/644066#M192327</link>
      <description>&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;It's exactly what I need!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank You very much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 20:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-with-increasing-dates-in-loop/m-p/644066#M192327</guid>
      <dc:creator>Irena_ik</dc:creator>
      <dc:date>2020-04-29T20:07:35Z</dc:date>
    </item>
  </channel>
</rss>

