<?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 yrdif function : act/act vs age in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648370#M194196</link>
    <description>&lt;P&gt;Hello, i want to ask a question about two options of yrdif function : 'ACT/ACT' vs 'AGE'&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;yr_act_act = yrdif(startdate, enddate, 'act/act');
yr_age = yrdif(startdate, enddate, 'AGE');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;1. 'Age' options is most accurate, it takes into account for example, leap year, right?&lt;/P&gt;&lt;P&gt;2. What is difference between two options?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 17 May 2020 07:38:02 GMT</pubDate>
    <dc:creator>AlexeyS</dc:creator>
    <dc:date>2020-05-17T07:38:02Z</dc:date>
    <item>
      <title>yrdif function : act/act vs age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648370#M194196</link>
      <description>&lt;P&gt;Hello, i want to ask a question about two options of yrdif function : 'ACT/ACT' vs 'AGE'&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;yr_act_act = yrdif(startdate, enddate, 'act/act');
yr_age = yrdif(startdate, enddate, 'AGE');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;1. 'Age' options is most accurate, it takes into account for example, leap year, right?&lt;/P&gt;&lt;P&gt;2. What is difference between two options?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 07:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648370#M194196</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2020-05-17T07:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: yrdif function : act/act vs age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648372#M194197</link>
      <description>&lt;P&gt;From the example given in the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;, ACT/ACT and AGE seem to be equivalent.&lt;/P&gt;
&lt;P&gt;But according to this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://books.google.at/books?id=Oie2BQAAQBAJ&amp;amp;pg=PA116&amp;amp;lpg=PA116&amp;amp;dq=sas+yrdif+act/act+age&amp;amp;source=bl&amp;amp;ots=YO9wwA91qV&amp;amp;sig=ACfU3U0bAKEvQ85K16jAfG9rJYgJAdakHA&amp;amp;hl=de&amp;amp;sa=X&amp;amp;ved=2ahUKEwiD1bjLxLrpAhXT8uAKHfWbBiIQ6AEwCXoECAYQAQ#v=onepage&amp;amp;q=sas%20yrdif%20act%2Fact%20age&amp;amp;f=false" target="_blank" rel="noopener"&gt;https://books.google.at/books?id=Oie2BQAAQBAJ&amp;amp;pg=PA116&amp;amp;lpg=PA116&amp;amp;dq=sas+yrdif+act/act+age&amp;amp;source=bl&amp;amp;ots=YO9wwA91qV&amp;amp;sig=ACfU3U0bAKEvQ85K16jAfG9rJYgJAdakHA&amp;amp;hl=de&amp;amp;sa=X&amp;amp;ved=2ahUKEwiD1bjLxLrpAhXT8uAKHfWbBiIQ6AEwCXoECAYQAQ#v=onepage&amp;amp;q=sas%20yrdif%20act%2Fact%20age&amp;amp;f=false&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;one should use AGE for age calculations.&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 09:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648372#M194197</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-17T09:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: yrdif function : act/act vs age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648376#M194199</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42503"&gt;@AlexeyS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is very weird indeed.&lt;/P&gt;
&lt;P&gt;In the documentation, the calculation seems to be the same, i.e. SAS takes into account leap years.&lt;/P&gt;
&lt;P&gt;However, the result is not exactly the same (even if the difference is slight and in the decimal part):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-05-17 à 11.45.58.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39536iA9AC8A0BC3B88739/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2020-05-17 à 11.45.58.png" alt="Capture d’écran 2020-05-17 à 11.45.58.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;SAS recommends the us of 'AGE' to calculates AGES.&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 09:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648376#M194199</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-17T09:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: yrdif function : act/act vs age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648387#M194208</link>
      <description>&lt;P&gt;The decimal difference is explained by the handling of the leap years, as the documentation states:&lt;/P&gt;
&lt;H4 class="xisDoc-argument"&gt;'ACT/ACT'&amp;nbsp; uses the actual number of days between dates in calculating the number of years. SAS calculates this value as the number of days that fall in 365-day years divided by 365 plus the number of days that fall in 366-day years divided by 366.&lt;/H4&gt;
&lt;P&gt;Year 2000 is a leap year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ONEDAY;
  YEAR_FRACTION=yrdif('01jan2000'd,'02jan2000'd,'age');      output;
  YEAR_FRACTION=1/365;                                       output;
  YEAR_FRACTION=yrdif('01jan2000'd,'02jan2000'd,'act/act');  output;
  YEAR_FRACTION=1/366;                                       output;
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE class="table" style="border-collapse: collapse; border-spacing: 0px; margin-bottom: 1em; border-width: 1px 0px 0px 1px; border-style: solid; border-color: #c1c1c1; border-image: initial; margin-left: auto; margin-right: auto; color: #000000; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #fafbfe; text-decoration-style: initial; text-decoration-color: initial;" aria-label="Data Set WORK.ONEDAY"&gt;&lt;CAPTION aria-label="Data Set WORK.ONEDAY"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL style="border-left: 1px solid #c1c1c1; border-right: 0px solid #c1c1c1;" /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TH class="r header" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #edf2f9; border-color: #b0b7bb; border-style: solid; border-width: 0px 1px 1px 0px; color: #112277; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: bold;" scope="col"&gt;YEAR_FRACTION&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#0000FF"&gt;.002739726&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#0000FF"&gt;.002739726&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#008000"&gt;.002732240&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#008000"&gt;.002732240&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;2020 is a leap year too. If you run your exact same test next year, using the today() function, there will be no difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ONEDAY;
  YEAR_FRACTION=yrdif('01jan2000'd,'02jan2000'd,'age');      output;
  YEAR_FRACTION=1/365;                                       output;
  YEAR_FRACTION=yrdif('01jan2000'd,'02jan2000'd,'act/act');  output;
  YEAR_FRACTION=1/366;                                       output;
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE class="table" style="border-collapse: collapse; border-spacing: 0px; margin-bottom: 1em; border-width: 1px 0px 0px 1px; border-style: solid; border-color: #c1c1c1; border-image: initial; margin-left: auto; margin-right: auto; color: #000000; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #fafbfe; text-decoration-style: initial; text-decoration-color: initial;" aria-label="Data Set WORK.ONEDAY"&gt;&lt;CAPTION aria-label="Data Set WORK.ONEDAY"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL style="border-left: 1px solid #c1c1c1; border-right: 0px solid #c1c1c1;" /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TH class="r header" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #edf2f9; border-color: #b0b7bb; border-style: solid; border-width: 0px 1px 1px 0px; color: #112277; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: bold;" scope="col"&gt;YEAR_FRACTION&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#0000FF"&gt;.002739726&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#0000FF"&gt;.002739726&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#008000"&gt;.002732240&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;&lt;FONT color="#008000"&gt;.002732240&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Sun, 17 May 2020 11:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648387#M194208</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-17T11:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: yrdif function : act/act vs age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648394#M194212</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42503"&gt;@AlexeyS&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The algorithm of ACT/ACT is described in&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1aooomgewfnx2n1j6gv00p517ri" target="_blank" rel="noopener"&gt;Calculations That Use ACT/ACT Basis&lt;/A&gt;: "&lt;SPAN&gt;YRDIF=n365/365.0 + n366/366.0" with the numbers n365 and n366 of days (between start and end date) in a 365-day year or 366-day year, respectively. It should be noted that "between" means &lt;EM&gt;including&lt;/EM&gt; the start date, but &lt;EM&gt;excluding&lt;/EM&gt; the end date. That is, the date difference increases by 1/366 or 1/365&amp;nbsp;when the end date advances by one day, depending on whether the day before the new end date (i.e., the old end date) falls in a leap year or not.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The subsequent section&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p0f4lsrlxkerlnn1u7pqrin7t9lx" target="_blank" rel="noopener"&gt;Computing a Person’s Age&lt;/A&gt; is less precise, though. It appears that YRDIF(...,'AGE') also uses two different increments when the end date advances by one day: 0 (!) if the end date is a leap day (February 29th), else 1/365. That is, the result is 1/365 times the date difference reduced by the number of leap days greater than start date and less than or equal to end date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As a consequence, both algorithms should produce identical results &lt;EM&gt;if&lt;/EM&gt; only &lt;EM&gt;complete&lt;/EM&gt; leap years, if any, are involved because&amp;nbsp;a &lt;EM&gt;complete&lt;/EM&gt; leap year is counted as 1 year by both algorithms. More precisely, the results should be the same&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;if neither the start date nor the end date falls in a leap year&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;or if both dates&amp;nbsp;fall in a leap year &lt;EM&gt;and&lt;/EM&gt; day and month of the start date are the same as day and month of the end date&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;or if the start date is January 1st of a leap year and the end date falls in a non-leap year&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;or if the end date is January 1st of a leap year and the start date falls in a non-leap year (see exclusion of the end date mentioned above).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;In all other cases the date interval contains an&amp;nbsp;&lt;EM&gt;incomplete&lt;/EM&gt; leap year, which leads to different results (differences in both directions) because of the different increments (1/366 vs. 0 or 1/365).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In addition to the discrepancies due to the different algorithms we see tiny differences (like 4.44E-16) due to rounding errors. This must be considered (e.g., using the ROUND function with rounding unit 1e-9) in comparisons of results.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 13:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/yrdif-function-act-act-vs-age/m-p/648394#M194212</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-05-17T13:49:58Z</dc:date>
    </item>
  </channel>
</rss>

