<?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: Numeric dates not converted to dates properly in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708909#M26637</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Excel holds a date as number of days past since and including 01/01/1900 &lt;BR /&gt;(= 1 as a number);&lt;/P&gt;
&lt;P&gt;SAS holds the date as number of days past since and excluding 01/01/1960 &lt;BR /&gt;(= 0 as a number);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you enter any date in an excel cell and in sas variable and check the numeric difference - it is a constant.&lt;/P&gt;
&lt;P&gt;You can convert the numeric value using next formulas:&lt;/P&gt;
&lt;PRE&gt;converting date/time values from Excel to SAS.

SAS_date = Excel_date - 21916;
SAS_time = Excel_time * 86400;
SAS_date_time = (Excel_date_time - 21916) * 86400;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is no need to remember "magic" numbers.&amp;nbsp; Just use DATE ('30DEC1899'd) or TIME ('24:00:00't)&amp;nbsp; literals.&lt;/P&gt;
&lt;PRE&gt;257  data _null_;
258     offset = '30DEC1899'd ;
259     seconds = '24:00:00't ;
260     put (offset seconds) (= comma11.);
261  run;

offset=-21,916 seconds=86,400
&lt;/PRE&gt;
&lt;P&gt;PS The reason to use 30th instead of 31st is that Excel treats 1900 as a leap year (which it isn't).&lt;/P&gt;</description>
    <pubDate>Thu, 31 Dec 2020 19:06:34 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-12-31T19:06:34Z</dc:date>
    <item>
      <title>Numeric dates not converted to dates properly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708873#M26625</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The original excel table that I am importing into SAS Guide has dates in numeric formats like &lt;STRONG&gt;44275&lt;/STRONG&gt;, which is &lt;STRONG&gt;20. March 2021&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;In wizard while importing I set output to be date in form of DANDfdd.w. But the output date came out wrong: &lt;STRONG&gt;31.March 2081.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same wrong date I get if leave it as original through import wizard but try to change through code with format=DDMMYYP10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

select Maturity_date format=DDMMYYP10.
from work.'lrdb_sent_combine_30.11.202_0000'n (obs=100);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why am I getting the wrong date?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 09:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708873#M26625</guid>
      <dc:creator>KristinaT</dc:creator>
      <dc:date>2020-12-31T09:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric dates not converted to dates properly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708877#M26628</link>
      <description>&lt;P&gt;Answer is here: &lt;A href="https://communities.sas.com/t5/New-SAS-User/Excel-to-SAS-date-format-issues/m-p/539683#M7100" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Excel-to-SAS-date-format-issues/m-p/539683#M7100&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 12:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708877#M26628</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-31T12:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric dates not converted to dates properly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708883#M26630</link>
      <description>&lt;P&gt;Excel holds a date as number of days past since and including 01/01/1900 &lt;BR /&gt;(= 1 as a number);&lt;/P&gt;
&lt;P&gt;SAS holds the date as number of days past since and excluding 01/01/1960 &lt;BR /&gt;(= 0 as a number);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you enter any date in an excel cell and in sas variable and check the numeric difference - it is a constant.&lt;/P&gt;
&lt;P&gt;You can convert the numeric value using next formulas:&lt;/P&gt;
&lt;PRE&gt;converting date/time values from Excel to SAS.

SAS_date = Excel_date - 21916;
SAS_time = Excel_time * 86400;
SAS_date_time = (Excel_date_time - 21916) * 86400;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 13:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708883#M26630</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-12-31T13:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric dates not converted to dates properly</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708909#M26637</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Excel holds a date as number of days past since and including 01/01/1900 &lt;BR /&gt;(= 1 as a number);&lt;/P&gt;
&lt;P&gt;SAS holds the date as number of days past since and excluding 01/01/1960 &lt;BR /&gt;(= 0 as a number);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you enter any date in an excel cell and in sas variable and check the numeric difference - it is a constant.&lt;/P&gt;
&lt;P&gt;You can convert the numeric value using next formulas:&lt;/P&gt;
&lt;PRE&gt;converting date/time values from Excel to SAS.

SAS_date = Excel_date - 21916;
SAS_time = Excel_time * 86400;
SAS_date_time = (Excel_date_time - 21916) * 86400;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is no need to remember "magic" numbers.&amp;nbsp; Just use DATE ('30DEC1899'd) or TIME ('24:00:00't)&amp;nbsp; literals.&lt;/P&gt;
&lt;PRE&gt;257  data _null_;
258     offset = '30DEC1899'd ;
259     seconds = '24:00:00't ;
260     put (offset seconds) (= comma11.);
261  run;

offset=-21,916 seconds=86,400
&lt;/PRE&gt;
&lt;P&gt;PS The reason to use 30th instead of 31st is that Excel treats 1900 as a leap year (which it isn't).&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 19:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Numeric-dates-not-converted-to-dates-properly/m-p/708909#M26637</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-31T19:06:34Z</dc:date>
    </item>
  </channel>
</rss>

