<?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: How to read the timestamp in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61774#M13425</link>
    <description>You have to use a INformat to read data. Formats are used to write data.&lt;BR /&gt;
ANYDTDTMw. is a very convenient informat to read datetime values as it digests a number of different datetime STRINGS and converts them to a number representing a SAS datetime.&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001239776.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001239776.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
What do you mean by "field is numeric"? Where do you try to read the data from? Could it be that this is more a data conversion problem (i.e. from ORACLE to SAS)?&lt;BR /&gt;
&lt;BR /&gt;
If the field you want to read is already in SAS and contains a datetime value then it's only about: &lt;BR /&gt;
newvar=datetimevar;&lt;BR /&gt;
...and you might want to use a format to WRITE the values of this new var, i.e"&lt;BR /&gt;
format newvar datetime21.;&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001263753.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001263753.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Patrick</description>
    <pubDate>Mon, 17 Nov 2008 07:01:12 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2008-11-17T07:01:12Z</dc:date>
    <item>
      <title>How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61773#M13424</link>
      <description>Hi ,&lt;BR /&gt;
iam trying to read the data for time stamp which is in below format&lt;BR /&gt;
yyyy-mm-dd-hh.mm.ss.hshshs,please tell me which format can i use to read the data ,one more thing (field is numeric).</description>
      <pubDate>Mon, 17 Nov 2008 06:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61773#M13424</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-17T06:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61774#M13425</link>
      <description>You have to use a INformat to read data. Formats are used to write data.&lt;BR /&gt;
ANYDTDTMw. is a very convenient informat to read datetime values as it digests a number of different datetime STRINGS and converts them to a number representing a SAS datetime.&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001239776.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001239776.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
What do you mean by "field is numeric"? Where do you try to read the data from? Could it be that this is more a data conversion problem (i.e. from ORACLE to SAS)?&lt;BR /&gt;
&lt;BR /&gt;
If the field you want to read is already in SAS and contains a datetime value then it's only about: &lt;BR /&gt;
newvar=datetimevar;&lt;BR /&gt;
...and you might want to use a format to WRITE the values of this new var, i.e"&lt;BR /&gt;
format newvar datetime21.;&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001263753.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001263753.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Patrick</description>
      <pubDate>Mon, 17 Nov 2008 07:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61774#M13425</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-11-17T07:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61775#M13426</link>
      <description>thanx for your reply,&lt;BR /&gt;
actually i am reading the data from text file to sas dataset ,then i need to convert that  into datetime format&lt;BR /&gt;
In first dataset after file reader field is Character,after converting field is numeric&lt;BR /&gt;
value i ma getting from file is 2008-09-06-03.30.45.101010</description>
      <pubDate>Mon, 17 Nov 2008 08:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61775#M13426</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-17T08:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61776#M13427</link>
      <description>Perhaps this small sample can give you some hints&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
  datetime_txt = '2008-09-06-03.30.45.101010';&lt;BR /&gt;
&lt;BR /&gt;
  date_num = input(substr(datetime_txt,1,10), yymmdd10.);&lt;BR /&gt;
  time_num = input(substr(datetime_txt,12), time15.);&lt;BR /&gt;
&lt;BR /&gt;
  datetime_sas = date_num * 86400 + time_num;&lt;BR /&gt;
&lt;BR /&gt;
  put date_num date. time_num time. datetime_sas datetime22.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
You have many ways to import and format your datetime, date and time values. Your 'problem' is that you got the year first in your datetime text, where's SAS normally got it last. &lt;BR /&gt;
If you can find a SAS date function or informat/format then use it, and not the substr I use in the small sample above (its quick &lt;U&gt;and&lt;/U&gt; dirty - like my 'dirty' datetime transformation).</description>
      <pubDate>Mon, 17 Nov 2008 14:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61776#M13427</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2008-11-17T14:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61777#M13428</link>
      <description>data want;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input MyDateTimeVar ANYDTDTM.;&lt;BR /&gt;
  put 'As a number: ' MyDateTimeVar= '   Formatted: ' MyDateTimeVar= datetime21.;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
2008-09-06-03.30.45.101010 &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 19 Nov 2008 11:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61777#M13428</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-11-19T11:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61778#M13429</link>
      <description>Hi Patrick &lt;BR /&gt;
&lt;BR /&gt;
Your right - ANYDTDTM. is a much better solution - I have learned something new, I didt knew that informat - tx.</description>
      <pubDate>Wed, 19 Nov 2008 14:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61778#M13429</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2008-11-19T14:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61779#M13430</link>
      <description>ThanX  GeniZ&lt;BR /&gt;
i will try to user this now.........</description>
      <pubDate>Thu, 20 Nov 2008 07:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61779#M13430</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-20T07:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to read the timestamp in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61780#M13431</link>
      <description>Thanx patrick</description>
      <pubDate>Thu, 20 Nov 2008 07:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-the-timestamp-in-SAS/m-p/61780#M13431</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-20T07:11:06Z</dc:date>
    </item>
  </channel>
</rss>

