<?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: add different number of days to increment a given starting date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700651#M214445</link>
    <description>&lt;P&gt;You will want to RETAIN the computed date as you add more days to the date.&lt;/P&gt;
&lt;P&gt;INTNX function accepts numeric expressions for increment argument, so your are not limited to constants.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data increments;&lt;BR /&gt;  input days @@;&lt;BR /&gt;datalines;&lt;BR /&gt;6 10 2 1 5 8&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;  retain new_date '22dec1992'd;&lt;BR /&gt;  set increments;&lt;BR /&gt;&lt;BR /&gt;  if _n_ = 1 then output; &lt;BR /&gt;&lt;BR /&gt;  new_date = intnx('day', new_date, days);  * increment by the value of days variable;&lt;BR /&gt;  output;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 21 Nov 2020 05:05:45 GMT</pubDate>
    <dc:creator>RichardDeVen</dc:creator>
    <dc:date>2020-11-21T05:05:45Z</dc:date>
    <item>
      <title>add different number of days to increment a given starting date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700645#M214439</link>
      <description>&lt;P&gt;i am using infile to input a variable called "days". This variable has 6 observations (6,10,2,1,5,8). These values are number of days. Now I have a starting date i.e 22 Dec 1992. I want to create a new variable called "new_dates" in which the first value should be "22 dec 1992" and then incremented by each number of days&amp;nbsp;(6,10,2,1,5,8). I know about INTNX but that increments a constant value to a given date. Couldnt figure out how to deal with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 04:05:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700645#M214439</guid>
      <dc:creator>hastm</dc:creator>
      <dc:date>2020-11-21T04:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: add different number of days to increment a given starting date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700648#M214442</link>
      <description>&lt;P&gt;Add your values to the date literal '22dec1992'd, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do days=6,10,2,1,5,8;
    output;
  end;
run;

data want;
  set have;
  new_date=intnx('day','22dec1992'd,days);
  format new_date date9.;
  put days= new_date=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I inserted the PUT statement just so you can look at the log for the results, rather than opening dataset WANT to confirm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, to use your INFILE approach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile datalines;
  input days;
  new_date=intnx('day','22dec1992'd,days);
  format new_date date9.;
  put days= new_date=;
datalines;
6
10
2
1
5
8
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Nov 2020 04:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700648#M214442</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-11-21T04:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: add different number of days to increment a given starting date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700650#M214444</link>
      <description>&lt;P&gt;thanks for your reply. whats the pupose of this line. output is same with or without it&lt;/P&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;put days= new_date=;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also its adding days to given date in each row. but its not incrementing on the next dates.&lt;/P&gt;&lt;P&gt;6 days + 22 dec 1992 = &lt;FONT color="#3366FF"&gt;28 dec 1992&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;but then next date should be&lt;/P&gt;&lt;P&gt;10 days + &lt;FONT color="#3366FF"&gt;28 dec 1992&lt;/FONT&gt; = 7 jan 1993&lt;/P&gt;&lt;DIV class=" dgrid-row ui-state-default dgrid-row-even dgrid-selected ui-state-active"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 21 Nov 2020 04:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700650#M214444</guid>
      <dc:creator>hastm</dc:creator>
      <dc:date>2020-11-21T04:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: add different number of days to increment a given starting date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700651#M214445</link>
      <description>&lt;P&gt;You will want to RETAIN the computed date as you add more days to the date.&lt;/P&gt;
&lt;P&gt;INTNX function accepts numeric expressions for increment argument, so your are not limited to constants.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data increments;&lt;BR /&gt;  input days @@;&lt;BR /&gt;datalines;&lt;BR /&gt;6 10 2 1 5 8&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;  retain new_date '22dec1992'd;&lt;BR /&gt;  set increments;&lt;BR /&gt;&lt;BR /&gt;  if _n_ = 1 then output; &lt;BR /&gt;&lt;BR /&gt;  new_date = intnx('day', new_date, days);  * increment by the value of days variable;&lt;BR /&gt;  output;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 05:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700651#M214445</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-11-21T05:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: add different number of days to increment a given starting date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700652#M214446</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357986"&gt;@hastm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;thanks for your reply. whats the pupose of this line. output is same with or without it&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;put days= new_date=;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I explained that in my note - please re-read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;also its adding days to given date in each row. but its not incrementing on the next dates.
&lt;P&gt;6 days + 22 dec 1992 = &lt;FONT color="#3366FF"&gt;28 dec 1992&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;but then next date should be&lt;/P&gt;
&lt;P&gt;10 days + &lt;FONT color="#3366FF"&gt;28 dec 1992&lt;/FONT&gt; = 7 jan 1993&lt;/P&gt;
&lt;DIV class=" dgrid-row ui-state-default dgrid-row-even dgrid-selected ui-state-active"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And I should have re-read your initial question.&amp;nbsp; But&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12477"&gt;@RichardDeVen&lt;/a&gt;&amp;nbsp;has addressed it.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 05:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700652#M214446</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-11-21T05:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: add different number of days to increment a given starting date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700653#M214447</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12477"&gt;@RichardDeVen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 05:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-different-number-of-days-to-increment-a-given-starting-date/m-p/700653#M214447</guid>
      <dc:creator>hastm</dc:creator>
      <dc:date>2020-11-21T05:16:39Z</dc:date>
    </item>
  </channel>
</rss>

