<?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 Correct datetime informat for 2020-09-18T17:58:59-0700 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688041#M208946</link>
    <description>&lt;P&gt;What is the correct informat and format to use for a date-time field that looks like this?:&amp;nbsp; 2020-09-18T17:58:59-0700&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried&lt;/P&gt;&lt;P&gt;informat timestamp E8601Dz25.;&lt;/P&gt;&lt;P&gt;format timestamp E8601Dz25.;* B8601DX25.;&lt;/P&gt;&lt;P&gt;input participantId timestamp E8601Dz25. bNumber;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried&lt;/P&gt;&lt;P&gt;informat timestamp B8601DX25.;&lt;/P&gt;&lt;P&gt;format timestamp B8601DX25.;&lt;/P&gt;&lt;P&gt;input participantId timestamp E8601DX25. bNumber;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, I receive this error message:&amp;nbsp; NOTE: Invalid data for timestamp in line 1 8-32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried changing the length to match the number of characters in the date, i.e. 24&lt;/P&gt;&lt;P&gt;informat timestamp E8601Dz24.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This causes the next variable to be read incorrectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 21:46:10 GMT</pubDate>
    <dc:creator>TOM123</dc:creator>
    <dc:date>2020-09-30T21:46:10Z</dc:date>
    <item>
      <title>Correct datetime informat for 2020-09-18T17:58:59-0700</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688041#M208946</link>
      <description>&lt;P&gt;What is the correct informat and format to use for a date-time field that looks like this?:&amp;nbsp; 2020-09-18T17:58:59-0700&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried&lt;/P&gt;&lt;P&gt;informat timestamp E8601Dz25.;&lt;/P&gt;&lt;P&gt;format timestamp E8601Dz25.;* B8601DX25.;&lt;/P&gt;&lt;P&gt;input participantId timestamp E8601Dz25. bNumber;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried&lt;/P&gt;&lt;P&gt;informat timestamp B8601DX25.;&lt;/P&gt;&lt;P&gt;format timestamp B8601DX25.;&lt;/P&gt;&lt;P&gt;input participantId timestamp E8601DX25. bNumber;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, I receive this error message:&amp;nbsp; NOTE: Invalid data for timestamp in line 1 8-32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried changing the length to match the number of characters in the date, i.e. 24&lt;/P&gt;&lt;P&gt;informat timestamp E8601Dz24.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This causes the next variable to be read incorrectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 21:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688041#M208946</guid>
      <dc:creator>TOM123</dc:creator>
      <dc:date>2020-09-30T21:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Correct datetime informat for 2020-09-18T17:58:59-0700</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688042#M208947</link>
      <description>&lt;P&gt;Show the entire log for that data step.&lt;/P&gt;
&lt;P&gt;Including the bit where SAS shows the invalid data line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think part of your problem is that the time offset is not correct for the informat. Note this works:&lt;/P&gt;
&lt;PRE&gt;data example;
  input x e8601dz.;
  format x datetime16.;
datalines;
2020-09-18T17:58:59-07:00
;&lt;/PRE&gt;
&lt;P&gt;So you need to insert a : in the time offset before using Input. One way, read the value into a string variable long enough to hold the value plus an inserted colon character, do the insert and input the result.&lt;/P&gt;
&lt;PRE&gt;data example;
  length xstr $ 26.;
  input xstr :$25.;
  x = input(catx(':',substr(xstr,1,22),substr(xstr,23)),e8601dz.);
  format x datetime16.;
datalines;
2020-09-18T17:58:59-0700
;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 22:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688042#M208947</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-30T22:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Correct datetime informat for 2020-09-18T17:58:59-0700</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688044#M208949</link>
      <description>&lt;P&gt;Can't share the data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 22:19:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688044#M208949</guid>
      <dc:creator>TOM123</dc:creator>
      <dc:date>2020-09-30T22:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: Correct datetime informat for 2020-09-18T17:58:59-0700</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688045#M208950</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; I will try this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 22:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688045#M208950</guid>
      <dc:creator>TOM123</dc:creator>
      <dc:date>2020-09-30T22:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Correct datetime informat for 2020-09-18T17:58:59-0700</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688046#M208951</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350119"&gt;@TOM123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can't share the data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The issue as I stated is with the value of the offset. If it only occurs for one value in the input file then easiest may be to insert the : in a plain text editor.&lt;/P&gt;
&lt;P&gt;If you have a mix of values with the offset having : and some not then you will need to parse the individual values and implement something similar to my second example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 22:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Correct-datetime-informat-for-2020-09-18T17-58-59-0700/m-p/688046#M208951</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-30T22:31:48Z</dc:date>
    </item>
  </channel>
</rss>

