<?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: adding days to start date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/adding-days-to-start-date/m-p/665812#M199132</link>
    <description>&lt;P&gt;I suspect that you want:&lt;/P&gt;
&lt;PRE&gt;if missing(days) then stop_dtm = intnx('dtday', start_dtm, 7,'S');&lt;/PRE&gt;
&lt;P&gt;the S, alignment, in the last position means "same", as in the same hour and minute. Default is 'B' or begin for the Intnx function would would advance to the start of the day or 00:00:00&lt;/P&gt;
&lt;P&gt;(you didn't show the result you were getting).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: you may want to make sure that your dates display with 4 digit years.&lt;/P&gt;
&lt;P&gt;And without your actual values and the complete code of a data step it really isn't possible to tell why something goes "wrong".&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;</description>
    <pubDate>Mon, 29 Jun 2020 15:08:52 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-06-29T15:08:52Z</dc:date>
    <item>
      <title>adding days to start date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-days-to-start-date/m-p/665807#M199130</link>
      <description>&lt;P&gt;I have the following dataset. What I would like to do is that if day is blank then add 7 days to start_dtm&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="245"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="34"&gt;ptid&lt;/TD&gt;
&lt;TD width="80"&gt;days&lt;/TD&gt;
&lt;TD width="131"&gt;start_dtm&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;03DEC19:04:35:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;TABLE width="376"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="34"&gt;ptid&lt;/TD&gt;
&lt;TD width="80"&gt;days&lt;/TD&gt;
&lt;TD width="131"&gt;start_dtm&lt;/TD&gt;
&lt;TD width="131"&gt;stop_dtm&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;03DEC19:04:35:00&lt;/TD&gt;
&lt;TD&gt;10DEC19:04:35:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried both codes and doesn't work:&lt;/P&gt;
&lt;P&gt;if missing(days) then stop_dtm =&amp;nbsp;intnx('dtday', start_dtm, 7);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ALSO&lt;/P&gt;
&lt;P&gt;if missing(days) then stop_dtm =&amp;nbsp; start_dtm + 7*24*60*60&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but i am getting 01Jan20:23:59 for stop date&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 14:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-days-to-start-date/m-p/665807#M199130</guid>
      <dc:creator>monday89</dc:creator>
      <dc:date>2020-06-29T14:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: adding days to start date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-days-to-start-date/m-p/665812#M199132</link>
      <description>&lt;P&gt;I suspect that you want:&lt;/P&gt;
&lt;PRE&gt;if missing(days) then stop_dtm = intnx('dtday', start_dtm, 7,'S');&lt;/PRE&gt;
&lt;P&gt;the S, alignment, in the last position means "same", as in the same hour and minute. Default is 'B' or begin for the Intnx function would would advance to the start of the day or 00:00:00&lt;/P&gt;
&lt;P&gt;(you didn't show the result you were getting).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: you may want to make sure that your dates display with 4 digit years.&lt;/P&gt;
&lt;P&gt;And without your actual values and the complete code of a data step it really isn't possible to tell why something goes "wrong".&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;</description>
      <pubDate>Mon, 29 Jun 2020 15:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-days-to-start-date/m-p/665812#M199132</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T15:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: adding days to start date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-days-to-start-date/m-p/665813#M199133</link>
      <description>&lt;P&gt;Try running the code I included. It looks like both those approaches will add seven days. (The second one will ensure the timestamp is correct.)&lt;/P&gt;
&lt;P&gt;How are you getting&amp;nbsp;&lt;SPAN&gt;01Jan20:23:59 for the stop date? Could you include the exact code you ran for that?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input ptid days start_dtm :datetime16.;
    format start_dtm datetime16.;
    datalines;
    1 . 03DEC19:04:35:00
    ;
run;

data want;
    set have;
    format stop_dtm stop_dtm2 datetime16.;
    if missing(days) then stop_dtm = intnx('dtday', start_dtm, 7);
    if missing(days) then stop_dtm2 =  start_dtm + 7*24*60*60;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 15:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-days-to-start-date/m-p/665813#M199133</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-06-29T15:09:00Z</dc:date>
    </item>
  </channel>
</rss>

