<?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 in years from SAS dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/computing-age-in-years-from-SAS-dates/m-p/841400#M36479</link>
    <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two variables: start_year and end_year. start_year is in recorded in years and in format numeric 8. while end_year is mmddyy10.&lt;/P&gt;
&lt;P&gt;i have tried to subtract and get the age but i keep getting funny values even with some of the codes i found.&lt;/P&gt;
&lt;P&gt;Attached is the simplest code i tried, your help is highly appreciated.&lt;/P&gt;
&lt;P&gt;sample data.&lt;/P&gt;
&lt;P&gt;start_date (8.)&amp;nbsp; end_date(mmddyy10.)&lt;/P&gt;
&lt;P&gt;2015&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/02/2017&lt;/P&gt;
&lt;P&gt;2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/07/2014&lt;/P&gt;
&lt;P&gt;2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/06/2019&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
format end_date year4.;&lt;BR /&gt;end_date2  = end_date;&lt;BR /&gt;format end_date2 8.;
age = end_date2 - start_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Oct 2022 23:15:15 GMT</pubDate>
    <dc:creator>Banke</dc:creator>
    <dc:date>2022-10-28T23:15:15Z</dc:date>
    <item>
      <title>computing age in years from SAS dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/computing-age-in-years-from-SAS-dates/m-p/841400#M36479</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two variables: start_year and end_year. start_year is in recorded in years and in format numeric 8. while end_year is mmddyy10.&lt;/P&gt;
&lt;P&gt;i have tried to subtract and get the age but i keep getting funny values even with some of the codes i found.&lt;/P&gt;
&lt;P&gt;Attached is the simplest code i tried, your help is highly appreciated.&lt;/P&gt;
&lt;P&gt;sample data.&lt;/P&gt;
&lt;P&gt;start_date (8.)&amp;nbsp; end_date(mmddyy10.)&lt;/P&gt;
&lt;P&gt;2015&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/02/2017&lt;/P&gt;
&lt;P&gt;2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/07/2014&lt;/P&gt;
&lt;P&gt;2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/06/2019&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
format end_date year4.;&lt;BR /&gt;end_date2  = end_date;&lt;BR /&gt;format end_date2 8.;
age = end_date2 - start_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Oct 2022 23:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/computing-age-in-years-from-SAS-dates/m-p/841400#M36479</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-10-28T23:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: computing age in years from SAS dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/computing-age-in-years-from-SAS-dates/m-p/841402#M36480</link>
      <description>&lt;P&gt;The calculation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age = end_date2 - start_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would generate the same result no matter what format you apply to the end_date2 and start_date variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need a function to extract the YEAR component of the end_date value (which is numerically the number of days after 01jan1960).&amp;nbsp; So use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  age = year(end_date) - start_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, this will return the same value for the entire 365 (or 366) days that END_DATE might have over the course of a single calendar year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 23:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/computing-age-in-years-from-SAS-dates/m-p/841402#M36480</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-10-28T23:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: computing age in years from SAS dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/computing-age-in-years-from-SAS-dates/m-p/841403#M36481</link>
      <description>Thank you so much!</description>
      <pubDate>Fri, 28 Oct 2022 23:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/computing-age-in-years-from-SAS-dates/m-p/841403#M36481</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-10-28T23:31:36Z</dc:date>
    </item>
  </channel>
</rss>

