<?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: Convert Numeric to Date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601579#M16732</link>
    <description>&lt;P&gt;Simply use an appropriate format to display the value correctly. And use the Datepart Function to display the value as a date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    dt=1878249600;
    d =datepart(dt);
    put dt = datetime20. // d= date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt=09JUL2019:00:00:00

d=09JUL2019&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Nov 2019 06:40:02 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-05T06:40:02Z</dc:date>
    <item>
      <title>Convert Numeric to Date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601578#M16731</link>
      <description>&lt;P&gt;Good day&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A datetime field was incorrectly stored (into a new table) as numeric 8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Original Date value of 9 July 2019 is stored as&amp;nbsp;1878249600. I think this includes the date and time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I convert the numeric field back to a datetime or date9 field.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 06:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601578#M16731</guid>
      <dc:creator>DarrylLawrence</dc:creator>
      <dc:date>2019-11-05T06:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric to Date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601579#M16732</link>
      <description>&lt;P&gt;Simply use an appropriate format to display the value correctly. And use the Datepart Function to display the value as a date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    dt=1878249600;
    d =datepart(dt);
    put dt = datetime20. // d= date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt=09JUL2019:00:00:00

d=09JUL2019&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Nov 2019 06:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601579#M16732</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-05T06:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric to Date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601580#M16733</link>
      <description>&lt;P&gt;Just apply a SAS datetime format to the variable. For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format MyDatetime datetime22.2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Nov 2019 06:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601580#M16733</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-11-05T06:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric to Date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601582#M16734</link>
      <description>&lt;P&gt;SAS date and datetime values are stored as numeric and a length of 8 is correct as well. The number you see looks like a SAS datetime value which is nothing else than the count of seconds since 1/1/1960.&lt;/P&gt;
&lt;P&gt;The only thing you need to do is apply a SAS format to the numerical column so your SAS datetime value becomes human readable. &lt;A href="https://go.documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;Here&lt;/A&gt; the docu explaining this much better than I can.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  dttm=1878249600;
  dttm2=dttm;
  dttm3=dttm;
  format dttm2 datetime21. dttm3 B8601DN10.;
  output;
  stop;
run;

proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 329px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33641i3273BD76BF93F679/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 06:45:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601582#M16734</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-11-05T06:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric to Date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601583#M16735</link>
      <description>&lt;P&gt;Thanks Patrick&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried it and it works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes the simplest answer is the best. I was trying many different ways to convert the number to a date and in the end it just needed to be formatted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 06:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Numeric-to-Date/m-p/601583#M16735</guid>
      <dc:creator>DarrylLawrence</dc:creator>
      <dc:date>2019-11-05T06:55:19Z</dc:date>
    </item>
  </channel>
</rss>

