<?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: DATETIME16.  incorrect years resulted using datepart and year functions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468668#M119748</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;check this out Chris. Any idea? let me know please&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ser_date = datepart(dt);
format ser_date date9.;
ser_year=year(ser_date);
X=ser_date;
if ser_year in (2054,2099,3000) then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="X=ser_date;   if ser_year in (2054,2099,3000) then output;" style="width: 361px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21105i2522FC57F30DC793/image-size/large?v=v2&amp;amp;px=999" role="button" title="chris.png" alt="X=ser_date;   if ser_year in (2054,2099,3000) then output;" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;X=ser_date;   if ser_year in (2054,2099,3000) then output;&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jun 2018 12:36:09 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2018-06-08T12:36:09Z</dc:date>
    <item>
      <title>DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468501#M119674</link>
      <description>&lt;P&gt;I have DATETIME16. variable and I had datepart and year from it just fine. However, some years were&amp;nbsp;output in&amp;nbsp;incorrect numbers, 3000, 2054 and 2099&amp;nbsp;from&amp;nbsp;same data step. Please help rectify this problem. Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="128" style="width: 96pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL width="64" style="width: 48pt;" span="2" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2005&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1147557&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2006&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1582890&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2007&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1723150&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2008&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1889702&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2009&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2118443&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2010&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2436944&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2011&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2389669&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2012&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2233374&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2013&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2466187&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2014&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2558208&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2015&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2321677&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2016&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1918775&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2017&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1023156&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2054&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2099&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="64" height="20" style="border-width: 0px 0px 0px 1pt; border-style: none none none solid; border-color: black black black rgb(193, 193, 193); width: 48pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;3000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64" align="right" style="border: 0px black; border-image: none; width: 48pt; background-color: transparent;"&gt;
&lt;P&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;2677&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata1; set mydata
ser_date = datepart(dt);
format ser_date date9.;
ser_year=year(ser_date);
run; 

proc freq data=mydata1;
tables ser_year;
run;

data test; set mydata1; 
if ser_year in (2054,2099,3000) then output;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Datepart and year() functions worked fine" style="width: 458px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21100iB2DE43677D6F9294/image-size/large?v=v2&amp;amp;px=999" role="button" title="date worked fine.png" alt="Datepart and year() functions worked fine" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Datepart and year() functions worked fine&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="The part where year is output 3000 instead 2000" style="width: 295px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21099i1184C2D8CE5AA748/image-size/large?v=v2&amp;amp;px=999" role="button" title="date not worked.png" alt="The part where year is output 3000 instead 2000" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;The part where year is output 3000 instead 2000&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 19:23:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468501#M119674</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-06-07T19:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468506#M119676</link>
      <description>&lt;P&gt;Since you used ANYDTDTM as the informat so I suspect the dates were read incorrectly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the underlying value for the incorrect dates, without any format. Its the number of seconds from Jan1 1960, so you can verify the ranges with some math to see if the underlying data is correct. I suspect it's not.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 19:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468506#M119676</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-07T19:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468516#M119680</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, data is given as is. I have no way of knowing underlying value. Looking at the screenshot 01JAN00:00:00:00, I'm tempted to take it as 01, Jan 2000. Would you agree?</description>
      <pubDate>Thu, 07 Jun 2018 19:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468516#M119680</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-06-07T19:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468534#M119686</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, data is given as is. I have no way of knowing underlying value. Looking at the screenshot 01JAN00:00:00:00, I'm tempted to take it as 01, Jan 2000. Would you agree?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;What is the original data source?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A text or Excel file?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 21:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468534#M119686</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-07T21:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468536#M119687</link>
      <description>SAS7dbat</description>
      <pubDate>Thu, 07 Jun 2018 21:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468536#M119687</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-06-07T21:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468538#M119688</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, data is given as is. I have no way of knowing underlying value. Looking at the screenshot 01JAN00:00:00:00, I'm tempted to take it as 01, Jan 2000. Would you agree?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Absolutely not. Each datetime width has different rules for display. When you use datetime16. it means the year will be displayed as 2 digits, and the last 2 at that.&lt;/P&gt;
&lt;P&gt;An example with two different centuries that display with the same "year" and the impact of the specific format chosen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x = '10Aug2005:00:00:00'dt;
   y = '10Aug2105:00:00:00'dt;
   format x y datetime16.;
run;
proc print;
run;

proc print;
  format x y datetime20.;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jun 2018 21:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468538#M119688</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-07T21:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468576#M119699</link>
      <description>&lt;P&gt;It looks like you have bad data.&lt;/P&gt;
&lt;P&gt;It may be because the anydtdte. informat misinterpreted some input values.&lt;/P&gt;
&lt;P&gt;Run this to create an unformatted variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test; 
  set mydata1; 
  X=DT;
  if ser_year in (2054,2099,3000) then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 02:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468576#M119699</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-06-08T02:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468577#M119700</link>
      <description>&lt;P&gt;You have a data integrity problem. You cannot assume that the date is 2000 safely, so you need to determine what the original data should be. An example of why it may be very wrong - there's often a trick used to avoid having to deal&amp;nbsp;with missing data - where you set the year to an arbitrarily large number to allow you to avoid having to explicitly deal with the case where it's missing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the dates with 3000 or missing years are identical - which from the example shown they appear to be - I suspect something like that may be the issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's also very unlikely a final stored SAS7BDAT file would have an informat of ANYDTDTM, I've usually only see that when PROC IMPORT was used to import data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;SAS7dbat&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 02:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468577#M119700</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-08T02:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468654#M119743</link>
      <description>Hi Chris, how does it help? Idata "test" has X and DT missing all the way and ser_year as numeric taking stated values.</description>
      <pubDate>Fri, 08 Jun 2018 11:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468654#M119743</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-06-08T11:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468658#M119746</link>
      <description>&lt;P&gt;1. How can you&amp;nbsp;have DT missing when you use it so:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;ser_date &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;datepart&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dt&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. It helps&amp;nbsp;because we can see the actual unformatted value.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 12:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468658#M119746</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-06-08T12:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468668#M119748</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;check this out Chris. Any idea? let me know please&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ser_date = datepart(dt);
format ser_date date9.;
ser_year=year(ser_date);
X=ser_date;
if ser_year in (2054,2099,3000) then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="X=ser_date;   if ser_year in (2054,2099,3000) then output;" style="width: 361px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21105i2522FC57F30DC793/image-size/large?v=v2&amp;amp;px=999" role="button" title="chris.png" alt="X=ser_date;   if ser_year in (2054,2099,3000) then output;" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;X=ser_date;   if ser_year in (2054,2099,3000) then output;&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 12:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468668#M119748</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-06-08T12:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468735#M119779</link>
      <description>&lt;P&gt;Show something from the original text file or data source. That is where the "problem" almost certainly comes from.&lt;/P&gt;
&lt;P&gt;Preferably identify the records with this odd behavior and find those to display.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468735#M119779</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-08T15:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468740#M119782</link>
      <description>&lt;P&gt;Check the records with the wrong years. If you only have 4 unique dates, there's something else going on, which appears to be the case.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468740#M119782</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-08T15:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468747#M119783</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, which 4 unique dates?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468747#M119783</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-06-08T15:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468761#M119785</link>
      <description>&lt;P&gt;For all the records with the years that seem weird, run a proc freq and see how many unique dates you have. If it's only 3 or 4 unique dates causing issues with the years, I suspect it's not the correct dates, but someone doing something weird with the data like I originally mentioned.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468761#M119785</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-08T15:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468805#M119793</link>
      <description>&lt;P&gt;Looks like your data have values for January 1 , 3000.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So a calculated year of 3000 is correct.&lt;/P&gt;
&lt;P&gt;So it looks like your original program is working correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS stores all numbers as floating point.&amp;nbsp; The DATE and DATETIME formats are just methods of display some numbers in ways that make them look like dates to humans.&lt;/P&gt;
&lt;P&gt;You didn't provide the original raw value of the input DT variable, but if I use the DHMS() function to convert the value you derived from it by using the DATEPART() function I see that it was 32,819,299,200.&lt;/P&gt;
&lt;PRE&gt;Raw Value  =   379,853
As DateTime=     05JAN1960:09:30:53
As Date    =01JAN3000

Raw Value  =      32,819,299,200
As DateTime=     01JAN3000:00:00:00
As Date    =*********
&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 17:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468805#M119793</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-08T17:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468891#M119824</link>
      <description>&lt;P&gt;Last time and why we keep asking about the file that was read.&lt;/P&gt;
&lt;P&gt;Here is an example of some possibly odd datetime values read with anydtdtm format.&lt;/P&gt;
&lt;P&gt;When you can explain how the result is derived for each one of these you might be ready to debug your original data that was read with that informat:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" style="background-color: rgb(234, 234, 234);"&gt;data junk;
  infile datalines truncover;
  input x anydtdtm40.;
  format x datetime20.;
datalines;
20.03.20.04.00.00
20.03.20.54.00.00
20.03.20.1054.00.00
20.03.20.154.00.00
20.03.2018.154.00.00
;
run;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;And so everyone doesn't have to actually run the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;                   x

  20MAR2020:04:00:00
  22MAR2020:06:00:00
  02MAY2020:22:00:00
  26MAR2020:10:00:00
  26MAR2018:10:00:00

&lt;/PRE&gt;
&lt;P&gt;Moral of the story: missing or extra characters in your source file can change the results in some pretty odd fashions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So find the records in the raw data and show the &lt;STRONG&gt;text&lt;/STRONG&gt; of the original values read with the informat and we can probably suggest either a fix or a change to the informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the original file was using proc import and that assigned the in anydtdtm informat&amp;nbsp; and the data is &lt;STRONG&gt;supposed&lt;/STRONG&gt; to have a consistent layout then this is an indication that SAS may have found something that did not match your expectations and grabbed that informat instead of a basic datetime informat because a number of values had odd characters or different lengths to be read.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 23:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468891#M119824</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-08T23:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468955#M119847</link>
      <description>&lt;P&gt;These dates are invalid.&lt;/P&gt;
&lt;P&gt;Since you won't make it easy to be helped, at least understand the response given by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;"&lt;SPAN&gt;Here is an example of some possibly odd datetime values read with anydtdtm format."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is probably why your dates are wrong.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jun 2018 23:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468955#M119847</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-06-09T23:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME16.  incorrect years resulted using datepart and year functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468956#M119848</link>
      <description>Hi Chris, I'm convinced that bad date has something to do how data was read into SAS data in the first place. I have no access to original file. I'm tempted to delete these records where years are 3000.</description>
      <pubDate>Sat, 09 Jun 2018 23:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DATETIME16-incorrect-years-resulted-using-datepart-and-year/m-p/468956#M119848</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2018-06-09T23:04:54Z</dc:date>
    </item>
  </channel>
</rss>

