<?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 Convert varchar variable to datetime format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776221#M31359</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date variable (eventtime) in my table in varchar format Eg:&lt;SPAN&gt;2021-10-18T16:33:30.388148Z. how can i convert the data type from varchar to utc date? Thank you!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Oct 2021 15:47:52 GMT</pubDate>
    <dc:creator>jayvisw11</dc:creator>
    <dc:date>2021-10-25T15:47:52Z</dc:date>
    <item>
      <title>Convert varchar variable to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776221#M31359</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date variable (eventtime) in my table in varchar format Eg:&lt;SPAN&gt;2021-10-18T16:33:30.388148Z. how can i convert the data type from varchar to utc date? Thank you!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 15:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776221#M31359</guid>
      <dc:creator>jayvisw11</dc:creator>
      <dc:date>2021-10-25T15:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert varchar variable to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776238#M31370</link>
      <description>&lt;P&gt;VARCHAR where? Basic SAS data sets only have Character and Numeric? Is this in an external database? FedSQL?&lt;/P&gt;
&lt;P&gt;Create a new variable using input with the correct informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are Informats&amp;nbsp; E8601DZw.d and E8601LZw.d, depending on whether you want a standard timezone or local for the Z,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you might want:&lt;/P&gt;
&lt;P&gt;newvar = input (yourunamedvariable,E8601dz27.6);&lt;/P&gt;
&lt;P&gt;Assign a desired format, possibly one of the E8601 flavors, for people to understand.&lt;/P&gt;
&lt;P&gt;Is the time actually accurate to a millionth of a second???&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 17:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776238#M31370</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-25T17:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert varchar variable to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776249#M31371</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;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;Is the time actually accurate to a millionth of a second???&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not if the dates are after the middle of 1988.&lt;/P&gt;
&lt;PRE&gt;40    data test;
41      dt=constant('exactint')/10E6 ;
42      put dt=comma32.6 /
43          dt=datetime27.6
44      ;
45    run;

dt=900,719,925.474099
dt=16JUL1988:23:58:45.474099
&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Oct 2021 17:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776249#M31371</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-25T17:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert varchar variable to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776253#M31372</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply. It is table created using FedSQL from an external database. E8601dz27.6 is the format of the value.&lt;BR /&gt;&lt;BR /&gt;data casuser.reporting_table_1;&lt;BR /&gt;set casuser.reporting_table_1;&lt;BR /&gt;eventtime_1 = input(eventtime,E8601dz27.6);&lt;BR /&gt;format eventtime_1 E8601DT.;&lt;BR /&gt;drop eventtime;&lt;BR /&gt;rename eventtime_1 = eventtime;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I ran this code, I still see that the eventtime variable data type is double instead of a datatime format.</description>
      <pubDate>Mon, 25 Oct 2021 17:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776253#M31372</guid>
      <dc:creator>jayvisw11</dc:creator>
      <dc:date>2021-10-25T17:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert varchar variable to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776254#M31373</link>
      <description>&lt;P&gt;On z/OS, it works because of the extra 4 bits of the mantissa.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 17:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776254#M31373</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-25T17:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Convert varchar variable to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776256#M31374</link>
      <description>&lt;P&gt;Does CAS support data types that SAS does not support?&amp;nbsp; In regular SAS datasets there are only two data types.&amp;nbsp; Fixed length character strings and floating point numbers.&amp;nbsp;The format attached to a variable just determines how the values are displayed as text, not the type of variable the values are stored in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATETIME values are just floating point numbers which are interpreted as the number of seconds since 1960.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 17:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776256#M31374</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-25T17:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert varchar variable to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776264#M31376</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/402145"&gt;@jayvisw11&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply. It is table created using FedSQL from an external database. E8601dz27.6 is the format of the value.&lt;BR /&gt;&lt;BR /&gt;data casuser.reporting_table_1;&lt;BR /&gt;set casuser.reporting_table_1;&lt;BR /&gt;eventtime_1 = input(eventtime,E8601dz27.6);&lt;BR /&gt;format eventtime_1 E8601DT.;&lt;BR /&gt;drop eventtime;&lt;BR /&gt;rename eventtime_1 = eventtime;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I ran this code, I still see that the eventtime variable data type is double instead of a datatime format.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The question would be does the formatted value look correct? The default length for the format you chose is 19 so the fractional seconds are not displayed. If the value is acceptable then your golden. Just remember your values will contain fractional seconds if you use them in comparisons and may yield the occasional unexpected result depending on what you compare them to.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 18:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-varchar-variable-to-datetime-format/m-p/776264#M31376</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-25T18:25:54Z</dc:date>
    </item>
  </channel>
</rss>

