<?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: Yrdif function - computation behind 30/360 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/453442#M114582</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST;    
  D1='01JAN2017'd; D2='16JAN2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
  D1='16JAN2017'd; D2='31JAN2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
  D1='01FEB2017'd; D2='15FEB2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
  D1='12FEB2017'd; D2='28FEB2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;X and Y give the same result. Does that make more sense now?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2018 05:09:59 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-04-12T05:09:59Z</dc:date>
    <item>
      <title>Yrdif function - computation behind 30/360</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452739#M114283</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data one;    
    _start='01JAN2017'd; _end='15JAN2017'd; dif=(15.5*30/31)/360;     output;
    _start='16JAN2017'd; _end='31JAN2017'd; dif=(15.5*30/31)/360;     output;
    _start='01FEB2017'd; _end='14FEB2017'd; dif=(13.06666*30/28)/360; output;
    _start='15FEB2017'd; _end='28FEB2017'd; dif=(14.93333*30/28)/360; output;
    _start='01MAR2017'd; _end='31MAR2017'd; dif=(31*30/31)/360;       output;
    _start='01APR2017'd; _end='11APR2017'd; dif=(11*30/30)/360;       output;
    _start='12APR2017'd; _end='20APR2017'd; dif=(9*30/30)/360;        output;
    _start='21APR2017'd; _end='30APR2017'd; dif=(10*30/30)/360;       output;
    _start='01MAY2017'd; _end='31MAY2017'd; dif=(31*30/31)/360;       output;
    _start='01JUN2017'd; _end='30JUN2017'd; dif=(30*30/30)/360;       output;
    _start='01JUL2017'd; _end='31JUL2017'd; dif=(31*30/31)/360;       output;
    _start='01AUG2017'd; _end='31AUG2017'd; dif=(31*30/31)/360;       output;
    _start='01SEP2017'd; _end='30SEP2017'd; dif=(30*30/30)/360;       output;
    _start='01OCT2017'd; _end='31OCT2017'd; dif=(31*30/31)/360;       output;
    _start='01NOV2017'd; _end='30NOV2017'd; dif=(30*30/30)/360;       output;
    _start='01DEC2017'd; _end='31DEC2017'd; dif=(31*30/31)/360;       output;
run;

data one;
    set one;
    yrdif_func=yrdif(_start,_end+1,'30/360');  
run;&lt;/PRE&gt;&lt;P&gt;Both dif and yrdif _func give the same result up to 6 digits after the comma in the example above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I cannot explain it. Indeed, I would expect something more like this for January and February:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data two;    
    _start='01JAN2017'd; _end='15JAN2017'd; dif=(15*30/31)/360; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _start='16JAN2017'd; _end='31JAN2017'd; dif=(16*30/31)/360; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _start='01FEB2017'd; _end='14FEB2017'd; dif=(14*30/28)/360; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _start='15FEB2017'd; _end='28FEB2017'd; dif=(14*30/28)/360; output;&lt;BR /&gt;    ...&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you aware of any reason for the way YRDIF is not matching my expectation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 08:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452739#M114283</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2018-04-10T08:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Yrdif function - computation behind 30/360</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452745#M114289</link>
      <description>&lt;P&gt;And did you read the SAS help documents on this?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which says:&lt;/P&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;basis&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;identifies a character constant or variable that describes how SAS calculates a date difference or a person’s age. The following character strings are valid:&lt;/P&gt;
&lt;DIV id="n1bji43m83eufcn1n29ixu7ac7ai" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;'30/360'&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;specifies a 30-day month and a 360-day year in calculating the number of years. Each month is considered to have 30 days, and each year 360 days, regardless of the actual number of days in each month or year.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-alias"&gt;Alias&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;'360'&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryTip"&gt;Tip&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;If either date falls at the end of a month, it is treated as if it were the last day of a 30-day month.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Apr 2018 08:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452745#M114289</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-10T08:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Yrdif function - computation behind 30/360</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452748#M114292</link>
      <description>&lt;P&gt;Yes, I read it but it didn't help me clarifying how the computation work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can only image this for computation and find it strange as for same interval of time, you don't get the same weight in the year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    _start='01JAN2017'd; _end='15JAN2017'd; dif=15/360; output;
    _start='16JAN2017'd; _end='31JAN2017'd; dif=30/360-15/360; output;
    _start='01FEB2017'd; _end='14FEB2017'd; dif=14/360; output;
    _start='15FEB2017'd; _end='28FEB2017'd; dif=30/360-14/360; output;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Apr 2018 09:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452748#M114292</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2018-04-10T09:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Yrdif function - computation behind 30/360</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452839#M114321</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184742"&gt;@xxformat_com&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;    
    _start='01JAN2017'd; _end='15JAN2017'd; dif=(15.5*30/31)/360;     output;
    _start='16JAN2017'd; _end='31JAN2017'd; dif=(15.5*30/31)/360;     output;
    _start='01FEB2017'd; _end='14FEB2017'd; dif=(13.06666*30/28)/360; output;
    _start='15FEB2017'd; _end='28FEB2017'd; dif=(14.93333*30/28)/360; output;
    _start='01MAR2017'd; _end='31MAR2017'd; dif=(31*30/31)/360;       output;
    _start='01APR2017'd; _end='11APR2017'd; dif=(11*30/30)/360;       output;
    _start='12APR2017'd; _end='20APR2017'd; dif=(9*30/30)/360;        output;
    _start='21APR2017'd; _end='30APR2017'd; dif=(10*30/30)/360;       output;
    _start='01MAY2017'd; _end='31MAY2017'd; dif=(31*30/31)/360;       output;
    _start='01JUN2017'd; _end='30JUN2017'd; dif=(30*30/30)/360;       output;
    _start='01JUL2017'd; _end='31JUL2017'd; dif=(31*30/31)/360;       output;
    _start='01AUG2017'd; _end='31AUG2017'd; dif=(31*30/31)/360;       output;
    _start='01SEP2017'd; _end='30SEP2017'd; dif=(30*30/30)/360;       output;
    _start='01OCT2017'd; _end='31OCT2017'd; dif=(31*30/31)/360;       output;
    _start='01NOV2017'd; _end='30NOV2017'd; dif=(30*30/30)/360;       output;
    _start='01DEC2017'd; _end='31DEC2017'd; dif=(31*30/31)/360;       output;
run;

data one;
    set one;
    yrdif_func=yrdif(_start,_end+1,'30/360');  
run;&lt;/PRE&gt;
&lt;P&gt;Both dif and yrdif _func give the same result up to 6 digits after the comma in the example above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However I cannot explain it. Indeed, I would expect something more like this for January and February:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data two;    
    _start='01JAN2017'd; _end='15JAN2017'd; dif=(15*30/31)/360; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _start='16JAN2017'd; _end='31JAN2017'd; dif=(16*30/31)/360; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _start='01FEB2017'd; _end='14FEB2017'd; dif=(14*30/28)/360; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _start='15FEB2017'd; _end='28FEB2017'd; dif=(14*30/28)/360; output;&lt;BR /&gt;    ...&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you aware of any reason for the way YRDIF is not matching my expectation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, what is your expectation? We can't read your mind.&lt;/P&gt;
&lt;P&gt;And what exactly are you attempting to do?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 14:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/452839#M114321</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-10T14:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Yrdif function - computation behind 30/360</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/453442#M114582</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST;    
  D1='01JAN2017'd; D2='16JAN2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
  D1='16JAN2017'd; D2='31JAN2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
  D1='01FEB2017'd; D2='15FEB2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
  D1='12FEB2017'd; D2='28FEB2017'd; X=(D2-D1)/360; Y=yrdif(D1,D2,'30/360'); output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;X and Y give the same result. Does that make more sense now?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 05:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/453442#M114582</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-04-12T05:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Yrdif function - computation behind 30/360</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/453532#M114611</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184742"&gt;@xxformat_com&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Do you understand the concept of "ultimo" used by banks for example for interest calculations? (...not sure if that applies for all countries).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically: Each month has max. 30 days, the year has 360 days, the last of the month is always day 30. Any day below 30 is counted as the exact day unless it's the last day of the month (so the last day of February is day 30; depending on leap year or not that's then 25, 26, 30&amp;nbsp; or 25, 26, 27, 30). So if you want the number of days since&amp;nbsp; - let's say 1/1/2017 then that's the 30*full months plus number of days of current month (set to 30 as well if last day of the current month).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So that's the logic&amp;nbsp;yrdif() with basis 360/30 uses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 class="xis-argument"&gt;'30/360'&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;specifies a 30-day month and a 360-day year in calculating the number of years. Each month is considered to have 30 days, and each year 360 days, regardless of the actual number of days in each month or year.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Apr 2018 13:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Yrdif-function-computation-behind-30-360/m-p/453532#M114611</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-04-12T13:00:54Z</dc:date>
    </item>
  </channel>
</rss>

