<?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 Differences Calculation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132731#M36114</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you subtract a date from another date you get the number of days between the values. Since SAS uses a base of 01Jan1960 for 'date' 0 then 59 days later is 29 Feb 1960.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to get a count of specific intervals, such as months or weeks you want the INTCK function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Nov 2013 22:26:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2013-11-04T22:26:02Z</dc:date>
    <item>
      <title>Date Differences Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132730#M36113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;data myfile;&lt;/P&gt;&lt;P&gt;set file1;&lt;/P&gt;&lt;P&gt;tdy=&amp;amp;pbd_date;&lt;/P&gt;&lt;P&gt;ckdt=CK007_dt;&lt;/P&gt;&lt;P&gt;age=tdy-ckdt;&lt;/P&gt;&lt;P&gt;format age date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In our database &amp;amp;pbd_date is a numeric that can be converted to a date format.&amp;nbsp; ckdt is also a numeric&lt;/P&gt;&lt;P&gt;When I run the code, it initially produces numerics and a difference (ie 19663 - 19604 = 59)&lt;/P&gt;&lt;P&gt;If I format the age variable to a date9 I get wierd dates in the past (ie 19663 - 19604 = 29FEB1960)&lt;/P&gt;&lt;P&gt;If I format tdy ckdt age to date9 I get something like (01NOV2013-03SEP2013=29FEB1960)&lt;/P&gt;&lt;P&gt;I want the difference between 11/1/13 and 9/1/13 to be expressed in the actual date that is between the tdy and ck_dt.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2013 21:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132730#M36113</guid>
      <dc:creator>gnt1986</dc:creator>
      <dc:date>2013-11-04T21:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Date Differences Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132731#M36114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you subtract a date from another date you get the number of days between the values. Since SAS uses a base of 01Jan1960 for 'date' 0 then 59 days later is 29 Feb 1960.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to get a count of specific intervals, such as months or weeks you want the INTCK function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2013 22:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132731#M36114</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-11-04T22:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Date Differences Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132732#M36115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure why you are calling your result "age" but, from what you described, does the following come close?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let pbd_date=19663;&lt;/P&gt;&lt;P&gt;data file1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat ck007_dt date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input ck007_dt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;03sep2013&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myfile;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set file1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tdy=&amp;amp;pbd_date;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ckdt=CK007_dt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; age=tdy+((tdy-ckdt)/2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; format age date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2013 22:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132732#M36115</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-11-04T22:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Date Differences Calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132733#M36116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would use intck ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dates;&lt;BR /&gt; format d_now dob date9.;&lt;BR /&gt; d_now=today();&lt;BR /&gt; dob="1jan1970"d;&lt;BR /&gt; age_years=intck('years',dob,d_now);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=dates; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d_now&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dob&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; age_years &lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 05NOV2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01JAN1970&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 43&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Nov 2013 22:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-Differences-Calculation/m-p/132733#M36116</guid>
      <dc:creator>MumSquared</dc:creator>
      <dc:date>2013-11-04T22:45:10Z</dc:date>
    </item>
  </channel>
</rss>

