<?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: how to find is this year leap year or not in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/614635#M179731</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31427"&gt;@gkeeler&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You're missing some refinement as noted in above comments:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) These extra days occur in years which are multiples of four (with &lt;BR /&gt;the exception of centennial years not divisible by 400).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) A rule has be proposed to make the year 4000 not a leap year&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; as a correction.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just include more dates in the list to find out if SAS is implementing those rules properly.&amp;nbsp; Looks like it does the 400 multiples right but it still considers 4,000 as a non-leap year.&amp;nbsp; SAS only has a little less than 1,980 years to adjust how they handle years that are multiples of 4000, assuming that the proposed rule is adopted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 do yr=2000,2016 to 2020,2100,4000 ;
   leapyr = 29 = day(mdy(3,1,yr)-1);
   put yr= leapyr= ;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;yr=2000 leapyr=1
yr=2016 leapyr=1
yr=2017 leapyr=0
yr=2018 leapyr=0
yr=2019 leapyr=0
yr=2020 leapyr=1
yr=2100 leapyr=0
yr=4000 leapyr=0
&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Jan 2020 05:35:43 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-01-01T05:35:43Z</dc:date>
    <item>
      <title>how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481393#M124517</link>
      <description />
      <pubDate>Thu, 26 Jul 2018 08:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481393#M124517</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-07-26T08:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481395#M124518</link>
      <description>&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Leap_year" target="_blank"&gt;https://en.wikipedia.org/wiki/Leap_year&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*** Please review the "how to post a question" guidance presented underneath the Post my question button when posting a question.&amp;nbsp; The answers you get will rely on the information you post, hence using the body of the text to explain your issue, showing test data in the form of a datastep, showing what the output should look like etc. will yield you good answers.&amp;nbsp; I mean a simply google search results in first place to:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2016/02/19/calculate-leap-year-in-sas/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2016/02/19/calculate-leap-year-in-sas/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 09:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481395#M124518</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-26T09:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481396#M124519</link>
      <description>&lt;P&gt;Leapyears are years that can be divided by four, except every 100th year, but including every 400th year. Use the mod() function for this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input year;
leapyear = (mod(year,4) = 0) and ((mod(year,100) ne 0) or (mod(year,400) = 0));
cards;
2018
2016
2000
1900
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that a simple fomula will perform better than a chain of if/else conditions.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 09:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481396#M124519</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-26T09:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481624#M124613</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;30 days hath September ....&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;463  data _null_;
464   do yr=2016 to 2020 ;
465     leapyr = 29 = day(mdy(3,1,yr)-1);
466     put yr= leapyr= ;
467   end;
468  run;

yr=2016 leapyr=1
yr=2017 leapyr=0
yr=2018 leapyr=0
yr=2019 leapyr=0
yr=2020 leapyr=1&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 17:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481624#M124613</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-26T17:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481660#M124629</link>
      <description>&lt;P&gt;Not quite:&lt;/P&gt;
&lt;PRE&gt;data test;
input year;
leapyear = (mod(year,4) = 0) and ((mod(year,100) ne 0) or (mod(year,400) = 0));
date= intnx('month',mdy(2,1,year),0,'e');
format date date9.;
cards;
2018
2016
2000
1900
2400
3000
4000
;
run;&lt;/PRE&gt;
&lt;P&gt;Your algorithm will indicate that year 4000 (and 8000, 12000, 16000 and 20000)&amp;nbsp;is a leap year incorrectly. Probably not of practical significance for most things but I ran into this when I had to convince some people that the SAS dates I was working with would be Y2K compliant and played around with the date functions and date values in SAS to push the limits a bit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INTNX doesn't want to deal with years past 20000 (currently).&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 19:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481660#M124629</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-26T19:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481671#M124632</link>
      <description>&lt;P&gt;So the formula needs an extension:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;leapyear = (mod(year,4) = 0) and ((mod(year,100) ne 0) or (mod(year,400) = 0 and mod(year,4000) ne 0));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;untested, as I'm on my tablet right now.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 20:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481671#M124632</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-26T20:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481790#M124704</link>
      <description>&lt;P&gt;Further research has brought me to the conclusion that&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;John Herschel has proposed the "4000 year rule" (among others)&lt;/LI&gt;
&lt;LI&gt;it improves the leap-year cycle&lt;/LI&gt;
&lt;LI&gt;but it is not (yet) officially adopted in the standards&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;so it's still up to the user to decide if to follow it or not.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2018 07:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/481790#M124704</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-27T07:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/614589#M179706</link>
      <description>&lt;P&gt;You're missing some refinement as noted in above comments:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) These extra days occur in years which are multiples of four (with &lt;BR /&gt;the exception of centennial years not divisible by 400).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) A rule has be proposed to make the year 4000 not a leap year&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; as a correction.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 17:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/614589#M179706</guid>
      <dc:creator>gkeeler</dc:creator>
      <dc:date>2019-12-31T17:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to find is this year leap year or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/614635#M179731</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31427"&gt;@gkeeler&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You're missing some refinement as noted in above comments:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) These extra days occur in years which are multiples of four (with &lt;BR /&gt;the exception of centennial years not divisible by 400).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) A rule has be proposed to make the year 4000 not a leap year&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; as a correction.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just include more dates in the list to find out if SAS is implementing those rules properly.&amp;nbsp; Looks like it does the 400 multiples right but it still considers 4,000 as a non-leap year.&amp;nbsp; SAS only has a little less than 1,980 years to adjust how they handle years that are multiples of 4000, assuming that the proposed rule is adopted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 do yr=2000,2016 to 2020,2100,4000 ;
   leapyr = 29 = day(mdy(3,1,yr)-1);
   put yr= leapyr= ;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;yr=2000 leapyr=1
yr=2016 leapyr=1
yr=2017 leapyr=0
yr=2018 leapyr=0
yr=2019 leapyr=0
yr=2020 leapyr=1
yr=2100 leapyr=0
yr=4000 leapyr=0
&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Jan 2020 05:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-is-this-year-leap-year-or-not/m-p/614635#M179731</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-01T05:35:43Z</dc:date>
    </item>
  </channel>
</rss>

