<?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: datetime informat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280869#M56839</link>
    <description>&lt;P&gt;If I do that then it just prints out 20 *'s (like this: ********************). Not sure why this is happenning&lt;/P&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 28 Jun 2016 18:07:00 GMT</pubDate>
    <dc:creator>ejohnson96</dc:creator>
    <dc:date>2016-06-28T18:07:00Z</dc:date>
    <item>
      <title>datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280840#M56825</link>
      <description>&lt;P&gt;I have a a UNIX datetime variable, and am trying to convert it into first a SAS datetime variable, and then use informat/formats to convert it to the format of yyyy-mm-dd hh:mm:ss but am having some trouble. The original datetime number has 13 digits.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is how to convert this 13 digit datetime from UNIX to SAS and then get it into the correct format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have read it in as numeric so I currently have a UNIXtimestamp variable that contains the 13 digits. Now I keep trying to convert it from UNIX to SAS and it's not working and it doesn't like my informat.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 16:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280840#M56825</guid>
      <dc:creator>ejohnson96</dc:creator>
      <dc:date>2016-06-28T16:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280849#M56830</link>
      <description>&lt;P&gt;What is the format of the UNIX timestamp?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 17:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280849#M56830</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-06-28T17:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280851#M56832</link>
      <description>&lt;P&gt;I am reading in and importing raw data from the web and this is the original format of the timestamp variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1139643118358&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's an example of one of the observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It says that it is measured in number of milliseconds from midnight on January 1st, 1970 (which I read is a UNIX timestamp). And I want to change it to a variable that looks like YYYY-MM-DD HH:MM:SS but measured in SAS, so from midnight on January 1st, 1960.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 17:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280851#M56832</guid>
      <dc:creator>ejohnson96</dc:creator>
      <dc:date>2016-06-28T17:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280860#M56835</link>
      <description>&lt;H2&gt;Usage Note &lt;I&gt;39499: &lt;/I&gt;Convert a UNIX datetime to a SAS® datetime&lt;/H2&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/39/499.html" target="_blank"&gt;http://support.sas.com/kb/39/499.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 17:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280860#M56835</guid>
      <dc:creator>Tim_SAS</dc:creator>
      <dc:date>2016-06-28T17:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280863#M56836</link>
      <description>&lt;P&gt;I copied this code but when I print out the data, the time variable still shows up just as numbers, not in the correct form.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS_time = dhms('01jan1970'd,0,0, UNIX_time);&lt;BR /&gt;informat SAS_time datetime20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UNIX_time is my original time variable, and I want the SAS_time variable to be printed in the data set in the form of:&lt;/P&gt;&lt;P&gt;YYYY-MM-DD HH:MM:SS&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 17:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280863#M56836</guid>
      <dc:creator>ejohnson96</dc:creator>
      <dc:date>2016-06-28T17:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280865#M56837</link>
      <description>&lt;P&gt;You didn't attach any format to your new variable. That is why it is still printing as raw number of seconds. &amp;nbsp;There is no value in attaching an INFORMAT to value you are not reading from raw text data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FORMAT SAS_DATETIME DATETIME20.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 18:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280865#M56837</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-06-28T18:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280869#M56839</link>
      <description>&lt;P&gt;If I do that then it just prints out 20 *'s (like this: ********************). Not sure why this is happenning&lt;/P&gt;&lt;DIV class="branch"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Jun 2016 18:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280869#M56839</guid>
      <dc:creator>ejohnson96</dc:creator>
      <dc:date>2016-06-28T18:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280870#M56840</link>
      <description>&lt;P&gt;That is SAS's way of showing that the value is too large or too small to fit the format. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check your values and figure out what is happening.&lt;/P&gt;
&lt;P&gt;If your number is number of seconds from 1/1/1970 then you can divide by 60*60*24*365.25 to get an estimate of the number of years since 1970 your number represents. &amp;nbsp;If result is&amp;nbsp;not in between 40 and 50 then you do not have a timestamp that is in his decade. &amp;nbsp;If you get a number between 40,000 and 50,000 then you might check if your source time is number of milliseconds instead of seconds.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  input t;
  days=(t/1000)/(24*60*60);
  years=days/365.25 ;
  put (_all_) (= best32. / );
  dt = dhms('01JAN1970'D,0,0,t/1000);
  put dt= datetime20. ;
cards;
1139643118358
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;t=1139643118358
days=13190.3138698842
years=36.1131112111821
dt=11FEB2006:07:31:58&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 18:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280870#M56840</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-06-28T18:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280908#M56854</link>
      <description>&lt;P&gt;It worked! Thanks so much for your help, it is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 20:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280908#M56854</guid>
      <dc:creator>ejohnson96</dc:creator>
      <dc:date>2016-06-28T20:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: datetime informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280933#M56863</link>
      <description>&lt;P&gt;Your number contains the milliseconds, the usage note doesn't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt; t; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt; unix_dtime=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;1139643118358&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt; Sas_dtime2 = dhms(&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;'01jan1970'd&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;, unix_dtime/&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;1000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="1"&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="1"&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="1"&gt;putlog&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt; SAS_dtime2 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#008080" face="SAS Monospace" size="1"&gt;datetime22.3&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;FONT color="#000080" face="SAS Monospace" size="1"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="1"&gt;&lt;FONT face="SAS Monospace" size="1"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;11FEB2006:07:31:58.358&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 22:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-informat/m-p/280933#M56863</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-06-28T22:24:02Z</dc:date>
    </item>
  </channel>
</rss>

