<?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: SAS EG: Numeric to timestamp in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275773#M19110</link>
    <description>&lt;P&gt;And for the somewhat obscure code of the week:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt; datetime = input(translate(put(x,&lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;f15.6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;),&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'T'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'.'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;), &lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;b8601dt.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2016 18:21:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-06-07T18:21:15Z</dc:date>
    <item>
      <title>SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275584#M19104</link>
      <description>&lt;P&gt;Good day,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the query builder in SAS EG 4.1.&lt;/P&gt;
&lt;P&gt;I am trying to convert a numeric to a timestamp and am not successful.&lt;/P&gt;
&lt;P&gt;Example: Numeric: 20091016.11415700&lt;/P&gt;
&lt;P&gt;Timestamp: 16OCT2009:11:41:57:000000&lt;/P&gt;
&lt;P&gt;I have attached pictures of the numeric and the timestamp format I require the data in.&lt;/P&gt;
&lt;P&gt;I have tried using the DHMS function with an informat of Datetime25.6&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12635i33E8F2B3CB304D1E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Numeric.png" title="Numeric.png" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12636i90960D7A0EE4BE03/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Timestamp.png" title="Timestamp.png" /&gt;</description>
      <pubDate>Tue, 07 Jun 2016 07:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275584#M19104</guid>
      <dc:creator>ahtinuS</dc:creator>
      <dc:date>2016-06-07T07:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275590#M19105</link>
      <description>&lt;P&gt;Before you click yourself to death in the query builder, just write some code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input _numeric;
cards;
20091016.114157
;
run;

data want (keep=_numeric _timestamp);
set have;
_year = int(_numeric/10000);
_month = int(_numeric/100) - _year * 100;
_day = int(_numeric) - _year * 10000 - _month * 100;
_date = mdy(_month,_day,_year);
_time = int((_numeric - int(_numeric)) * 1000000);
_hours = int(_time/10000);
_minutes = int(_time/100) - _hours * 100;
_seconds = int(_time) - _hours * 10000 - _minutes * 100;
_timestamp = dhms(_date,_hours,_minutes,_seconds);
format _timestamp datetime26.6;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that fractions of seconds cannot be used with your initial numeric notation, as they would exceed the maximum precision of SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 08:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275590#M19105</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-07T08:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275606#M19107</link>
      <description>Thank you for this.&lt;BR /&gt;I would still like to know how to do this in SAS EG.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Jun 2016 10:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275606#M19107</guid>
      <dc:creator>ahtinuS</dc:creator>
      <dc:date>2016-06-07T10:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275608#M19108</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8874"&gt;@ahtinuS&lt;/a&gt; wrote:&lt;BR /&gt;Thank you for this.&lt;BR /&gt;I would still like to know how to do this in SAS EG.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In a Code window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You see, since EG is nothing but a code generator, and everything in SAS is done through code, you WILL learn to work with code sooner or later.&lt;/P&gt;
&lt;P&gt;So why not start sooner?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 10:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275608#M19108</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-07T10:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275753#M19109</link>
      <description>&lt;P&gt;Well, here it is. Put in a new computed column, and then copy and paste this formula:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;dhms(mdy(int(ts/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;) - (int(ts/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;10000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)* &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;),&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;int(ts) - (int(ts/&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;) * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;int(ts/&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;10000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;int((ts - int(ts)) * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;int((ts * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; - int(ts * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)) * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;(ts * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;10000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; - int(ts * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;10000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;))*&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I usually charge at least one beer for this amount of effort!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very important to note, as&amp;nbsp;@kurtbremser does, that 8 byte floating point can't hold enough digits for you to get fractional seconds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Tom&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 17:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275753#M19109</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2016-06-07T17:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275773#M19110</link>
      <description>&lt;P&gt;And for the somewhat obscure code of the week:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt; datetime = input(translate(put(x,&lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;f15.6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;),&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'T'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'.'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;), &lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;b8601dt.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 18:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275773#M19110</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-07T18:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275779#M19111</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;And for the somewhat obscure code of the week:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt; datetime = input(translate(put(x,&lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;f15.6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;),&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'T'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'.'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;), &lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;b8601dt.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Simple and Brilliant. Wish I caught that.&lt;/P&gt;
&lt;P&gt;Actually, I don't think it is obscure at all.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 12:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275779#M19111</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-08T12:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275874#M19115</link>
      <description>&lt;P&gt;And for those who like the code:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;create table res_table as&lt;/P&gt;
&lt;P&gt;select t1.cfty_mfts&lt;/P&gt;
&lt;P&gt;/* calculation */&lt;/P&gt;
&lt;P&gt;(input(translate(put(t1.cfty_mfts,f15.6),'t','.'), b8601dt.)&lt;/P&gt;
&lt;P&gt;) format=datetime25.6 as calculation,&lt;/P&gt;
&lt;P&gt;from my_table;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 06:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275874#M19115</guid>
      <dc:creator>ahtinuS</dc:creator>
      <dc:date>2016-06-08T06:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275875#M19116</link>
      <description>&lt;P&gt;Here is the code that was generated:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;create table res_table as&lt;/P&gt;
&lt;P&gt;select t1.cfty_mfts&lt;/P&gt;
&lt;P&gt;/* calculation */&lt;/P&gt;
&lt;P&gt;(input(translate(put(t1.cfty_mfts,f15.6),'t','.'), b8601dt.)&lt;/P&gt;
&lt;P&gt;) format=datetime25.6 as calculation,&lt;/P&gt;
&lt;P&gt;from my_table;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 06:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275875#M19116</guid>
      <dc:creator>ahtinuS</dc:creator>
      <dc:date>2016-06-08T06:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG: Numeric to timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275936#M19122</link>
      <description>&lt;P&gt;Wow! I love it!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I never even thought to look at formats and informats for this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 12:04:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Numeric-to-timestamp/m-p/275936#M19122</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2016-06-08T12:04:06Z</dc:date>
    </item>
  </channel>
</rss>

