<?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: Converting a number to a date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-a-number-to-a-date/m-p/626091#M184612</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313030"&gt;@kevinharshads1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since SAS keeps dates/ datetimes as a number of days/seconds since January 1st 1960 I would start with adding proper format to the variable you have and then do the export to Excel, e.g.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture myDate (default=16)
          other='%Y/%0m/%0d %0H:%0M' (datatype=datetime);
run;

data want;
  set have;
  format myVariableName myDate.;
run;

proc export data = want ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Feb 2020 10:18:32 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2020-02-20T10:18:32Z</dc:date>
    <item>
      <title>Converting a number to a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-a-number-to-a-date/m-p/626089#M184611</link>
      <description>&lt;DIV class="_3xX726aBn29LDbsDtzr_6E _1Ap4F5maDtT1E1YuCiaO0r D3IL3FD0RFy_mkKLPwL4"&gt;&lt;DIV class="_292iotee39Lmt0MkQZ2hPV RichTextJSON-root"&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;I'm pulling data from a database to load into another database. The file spec I've been given says the date I need to provide be in yyyy/mm/dd hh:mm format.&lt;/P&gt;&lt;P class="_1qeIAgB0cPwnLhDF9XSiJM"&gt;The date field I'm pulling is in SQL Server and it's a datetime field, but from the SAS library side of things it shows as "Number". How can I have it export to my Excel export as a date, and in the yyyy/mm/dd hh:mm format? (e.g. 2019/04/01 00:00)&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="_1hwEKkB_38tIoal6fcdrt9"&gt;&lt;DIV class="_3-miAEojrCvx_4FQ8x3P-s"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 10:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-a-number-to-a-date/m-p/626089#M184611</guid>
      <dc:creator>kevinharshads1</dc:creator>
      <dc:date>2020-02-20T10:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a number to a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-a-number-to-a-date/m-p/626091#M184612</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/313030"&gt;@kevinharshads1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since SAS keeps dates/ datetimes as a number of days/seconds since January 1st 1960 I would start with adding proper format to the variable you have and then do the export to Excel, e.g.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture myDate (default=16)
          other='%Y/%0m/%0d %0H:%0M' (datatype=datetime);
run;

data want;
  set have;
  format myVariableName myDate.;
run;

proc export data = want ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 10:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-a-number-to-a-date/m-p/626091#M184612</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-02-20T10:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a number to a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-a-number-to-a-date/m-p/626202#M184659</link>
      <description>SAS stores dates and times as numbers, what matters on the SAS side is the format, which controls how it's displayed to the user. You need to apply the correct format to have it applied. However, I will say that when pulling directly from a Server datetimes usually come across perfectly fine  so does it actually look incorrect to you when viewing the data. SAS only has two types of data, character/numeric.</description>
      <pubDate>Thu, 20 Feb 2020 16:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-a-number-to-a-date/m-p/626202#M184659</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-20T16:24:36Z</dc:date>
    </item>
  </channel>
</rss>

