<?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: date duration format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491985#M129209</link>
    <description>&lt;P&gt;Do you have a datetime-variable or a char variable, that just looks like a datetime?&lt;/P&gt;
&lt;P&gt;Assuming the first, you can use the function intck to calculate the difference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var1 = intck("yeardt", date1, date2) &amp;gt;= 5;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Sep 2018 06:01:03 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-09-03T06:01:03Z</dc:date>
    <item>
      <title>date duration format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491984#M129208</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, thank you for all your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two dates, I want to generate a new variable var=1 if the difference between two dates is less than 5 years.&lt;/P&gt;&lt;P&gt;date 1: 2015/01/02 00:02:25&amp;nbsp;&lt;/P&gt;&lt;P&gt;date 2: 2014/04/21 09:21:36&lt;/P&gt;&lt;P&gt;Is it correct if I use the following condition:&lt;/P&gt;&lt;P&gt;0&amp;lt; date1 - date2 &amp;lt; 5 * 365.25 * 24 * 3600000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If not, which condition should I use? The date format is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;yyyy/mm/dd hh:mm:ss&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Freda&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 05:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491984#M129208</guid>
      <dc:creator>freda</dc:creator>
      <dc:date>2018-09-03T05:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: date duration format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491985#M129209</link>
      <description>&lt;P&gt;Do you have a datetime-variable or a char variable, that just looks like a datetime?&lt;/P&gt;
&lt;P&gt;Assuming the first, you can use the function intck to calculate the difference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var1 = intck("yeardt", date1, date2) &amp;gt;= 5;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Sep 2018 06:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491985#M129209</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-09-03T06:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: date duration format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491986#M129210</link>
      <description>&lt;P&gt;I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how ever a slight change use 'dtyear' instead of 'yeardt'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;var1 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"dtyear"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; date1&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; date2&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;5&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Sep 2018 06:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491986#M129210</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-09-03T06:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: date duration format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491990#M129213</link>
      <description>&lt;P&gt;For your purpose, I would also add a method to the intck function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var1 = intck("dtyear", date1, date2, 'C') &amp;gt;= 5;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In its default behaviour ('D' or 'Discrete'), the intck function would count the number of boundaries (00:00 on Jan 1st) over which the interval stretches, not the number of whole years (365.25 days) that have passed.&lt;/P&gt;
&lt;P&gt;IE&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input (date1 date2) (:yymmdd10.);
format date1 date2 yymmddd10.;
int1 = intck('year',date1,date2);
int2 = intck('year',date1,date2,'c');
cards;
2012-12-31 2017-01-01
2012-01-01 2017-12-31
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Sep 2018 07:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-duration-format/m-p/491990#M129213</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-03T07:04:24Z</dc:date>
    </item>
  </channel>
</rss>

