<?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: Calculate current age in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414816#M67530</link>
    <description>&lt;P&gt;I would like to use&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;age_at_clt &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; yrdif&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dob&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;clstartdate,'age'&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2017 12:45:52 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-11-20T12:45:52Z</dc:date>
    <item>
      <title>Calculate current age</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414775#M67525</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;I am attempting to calculate the age of individuals in my data set using their date of birth and the date their clinical treatment started.&amp;nbsp; Following that I will be attempting to create age groups according to their age at their addmitance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that this data is over a period of time, and individuals can have been admitted on multiple occasions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of the data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;clientid&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; clstartdate&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10435&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18309&lt;/P&gt;&lt;P&gt;122&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3982&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;19452&lt;/P&gt;&lt;P&gt;156&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-13125&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20065&lt;/P&gt;&lt;P&gt;189&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11497&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;17875&lt;/P&gt;&lt;P&gt;192&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10977&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;19912&lt;/P&gt;&lt;P&gt;&amp;nbsp;201&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3133&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20391&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I go about calculating their age?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 08:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414775#M67525</guid>
      <dc:creator>senac255</dc:creator>
      <dc:date>2017-11-20T08:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414776#M67526</link>
      <description>&lt;P&gt;Use the intck() function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input clientid dob clstartdate;
cards;
123 10435 18309
122 3982 19452
156 -13125 20065
189 11497 17875
192 10977 19912
201 3133 20391
;
run;

data want;
set have;
age_at_clt = intck('year',dob,clstartdate);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could use a basic calculation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age_at_clt = (clstartdate - dob) / 365.25;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or, for special types of "age":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age_at_clt = year(clstartdate) - year(dob);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So it's up to you to define what "age" is supposed to be in your context.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 08:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414776#M67526</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-20T08:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414782#M67527</link>
      <description>&lt;P&gt;Those calculations you give Kurt, are they accurate, I know the 365.25 is just an approximation, but how about the others?&amp;nbsp; I know for a long time we used:&lt;/P&gt;
&lt;PRE&gt;int((intck('month',&amp;lt;birth&amp;gt;,&amp;lt;start&amp;gt;)-(day(&amp;lt;birth&amp;gt;)&amp;gt; day(&amp;lt;start&amp;gt;))) /12)&lt;/PRE&gt;
&lt;P&gt;To get the most accurate age reading, but maybe the functions like year now cover this?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 09:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414782#M67527</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-20T09:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414785#M67528</link>
      <description>&lt;P&gt;Those three calculations were just the proverbial "tip of the iceberg".&lt;/P&gt;
&lt;P&gt;There are so many ways to go about it, and so much more ways to fine-tune those, that it will be up to the developer to determine which one to use in the end.&lt;/P&gt;
&lt;P&gt;It comes down to try those methods and compare their results with the desired outcome, over a sufficient lot of test cases. Just defining the test cases can be a major challenge (and is often the most important part of developing, I'm a big supporter of test-driven development).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 365.25 approximation should work reasonably well for timespans in the range of lifetimes. It depends if a "legal" age value is needed, or a value best suited for statistics.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 09:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414785#M67528</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-20T09:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414816#M67530</link>
      <description>&lt;P&gt;I would like to use&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;age_at_clt &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; yrdif&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dob&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;clstartdate,'age'&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 12:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/414816#M67530</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-20T12:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current age</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/415088#M67554</link>
      <description>The intck expression did the trick.&lt;BR /&gt;Thanks!</description>
      <pubDate>Tue, 21 Nov 2017 09:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-current-age/m-p/415088#M67554</guid>
      <dc:creator>senac255</dc:creator>
      <dc:date>2017-11-21T09:07:36Z</dc:date>
    </item>
  </channel>
</rss>

