<?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: converting dates to years in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612227#M18293</link>
    <description>&lt;P&gt;Thank you! The intck function worked.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2019 21:29:21 GMT</pubDate>
    <dc:creator>nturne</dc:creator>
    <dc:date>2019-12-16T21:29:21Z</dc:date>
    <item>
      <title>converting dates to years</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612095#M18284</link>
      <description>&lt;P&gt;Hi Sas users&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two dates in the format of mmddyy8. How can I convert these dates to years. See my code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data colon.service;&lt;BR /&gt;number_years=year(admdate-svcdate);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 17:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612095#M18284</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-12-16T17:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: converting dates to years</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612097#M18285</link>
      <description>&lt;P&gt;admdate-svcdate is the number of days between admdate and svcdate. To get approximate years, you divide by 365 or 365.25. To get exact years accounting for leap years, use the INTCK function or the YRDIF function.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612097#M18285</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-16T18:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: converting dates to years</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612098#M18286</link>
      <description>&lt;P&gt;The YEAR() function wants a date as input.&amp;nbsp; If you subtract two dates you will get some small number of days which the YEAR() function will then interpret as a date.&amp;nbsp; So if the difference in days is less than 365 then result will be a date in the year 1960 so applying the YEAR() function to it will return 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you want to define the difference in years?&amp;nbsp; Do you just want to subtract 2015 from 2019?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;number_years=year(admdate)-year(svcdate);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do you want to take the difference in days and divide by an average number of days in a year?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;number_years=(admdate-svcdate)/365.25 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps you want to use the INTCK() function to count for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 17:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612098#M18286</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-16T17:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: converting dates to years</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612100#M18287</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299242"&gt;@nturne&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the INTCK function,&amp;nbsp;which returns the count of the number of interval boundaries between two dates, two &lt;BR /&gt;times, or two datetime values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data service;
	input admdate:mmddyy8. svcdate:mmddyy8.;
	format admdate svcdate mmddyy8.;
	number_years=intck("year",admdate,svcdate);
	cards;
01/16/17 12/16/19
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 17:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612100#M18287</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-16T17:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: converting dates to years</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612227#M18293</link>
      <description>&lt;P&gt;Thank you! The intck function worked.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 21:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-dates-to-years/m-p/612227#M18293</guid>
      <dc:creator>nturne</dc:creator>
      <dc:date>2019-12-16T21:29:21Z</dc:date>
    </item>
  </channel>
</rss>

