<?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 computing age from datetime variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293603#M61146</link>
    <description>&lt;P&gt;I have a DOB variable as follows and I want to compute age from this variable&lt;/P&gt;&lt;P&gt;DOB&lt;/P&gt;&lt;P&gt;16JUL51:00:00:00&lt;/P&gt;&lt;P&gt;24NOV33:00:00:00&lt;/P&gt;&lt;P&gt;07MAY45:00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think INTCK can not be used in this case.&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;age = '24AUG16:00:00:00'd-DOB; but its giving me some wierd numbers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Experts I need your help !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Aug 2016 02:47:54 GMT</pubDate>
    <dc:creator>deega</dc:creator>
    <dc:date>2016-08-24T02:47:54Z</dc:date>
    <item>
      <title>computing age from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293603#M61146</link>
      <description>&lt;P&gt;I have a DOB variable as follows and I want to compute age from this variable&lt;/P&gt;&lt;P&gt;DOB&lt;/P&gt;&lt;P&gt;16JUL51:00:00:00&lt;/P&gt;&lt;P&gt;24NOV33:00:00:00&lt;/P&gt;&lt;P&gt;07MAY45:00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think INTCK can not be used in this case.&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;age = '24AUG16:00:00:00'd-DOB; but its giving me some wierd numbers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Experts I need your help !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 02:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293603#M61146</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2016-08-24T02:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: computing age from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293607#M61150</link>
      <description>&lt;P&gt;Please refer to this post.&lt;/P&gt;&lt;P&gt;Only difference in your question is date has time part, so apply datepart function on DOB column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Age-from-BirthDate/td-p/80935" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Age-from-BirthDate/td-p/80935&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 03:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293607#M61150</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-24T03:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: computing age from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293631#M61160</link>
      <description>&lt;P&gt;Both your values are datetime values, which means they are stored as numbers containing the seconds from 01jan1960:00:00:00.&lt;/P&gt;
&lt;P&gt;If you subtract them, you once again get a count of seconds, but one that can't be displayed with SAS datetime formats, as it would fall into the first century AD, where the Gregorian calendar doesn't work.&lt;/P&gt;
&lt;P&gt;If you use date values (date() and datepart(DOB)), you will get a count of days; to get years, use the intck() function with the correct parameters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input DOB:datetime20.;
format DOB datetime19.;
cards;
16JUL51:00:00:00
24NOV33:00:00:00
07MAY45:00:00:00
;
run;

data want;
set have;
age = intck('year',datepart(DOB),date());
run;

proc print noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;               DOB    age

16JUL1951:00:00:00     65
24NOV1933:00:00:00     83
07MAY1945:00:00:00     71
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 06:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293631#M61160</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-24T06:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: computing age from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293654#M61179</link>
      <description>&lt;PRE&gt;
The third parameter would be better.

age = intck('year',datepart(DOB),date(),'c');

&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Aug 2016 10:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293654#M61179</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-24T10:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: computing age from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293737#M61208</link>
      <description>&lt;P&gt;Actually I am thinking no need for DATEPART() at all:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age=intck('dtyear',dob,datetime(),'c');
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are native intervals built for datetime values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 14:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/computing-age-from-datetime-variable/m-p/293737#M61208</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-08-24T14:33:24Z</dc:date>
    </item>
  </channel>
</rss>

