<?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: proc sql date type convertion in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78453#M682</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the sas function timepart as well, timepart(your_variable) format=time8.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Jul 2012 19:38:05 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2012-07-30T19:38:05Z</dc:date>
    <item>
      <title>proc sql date type convertion</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78451#M680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm developing something using proc sql and just wondering if there is any way to convert a DATETIME25.6 type into a TIME8.0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From 28MAR2010:08:34:14.596704 to 8:34:14&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jul 2012 19:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78451#M680</guid>
      <dc:creator>Nehcour0420</dc:creator>
      <dc:date>2012-07-30T19:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql date type convertion</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78452#M681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try &lt;STRONG&gt;convert(varchar(12), your_dtime, 108) as "HH:MM:SS"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;where the varchar(??) is what your value is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jul 2012 19:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78452#M681</guid>
      <dc:creator>robby_beum</dc:creator>
      <dc:date>2012-07-30T19:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql date type convertion</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78453#M682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the sas function timepart as well, timepart(your_variable) format=time8.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jul 2012 19:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78453#M682</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-07-30T19:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql date type convertion</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78454#M683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your data lives in SAS datasets then there are only 2 variable types: character and numeric. There is no such thing like a type DATETIME25.6 or TIME8.0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What there is are numeric variables containing a SAS date, datetime or time value (date: number of days since 1Jan1960, datetime: number of seconds since 1Jan1960, time: number of seconds since midnight).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So as these are all numbers it's only about assigning an appropriate format to "print" the values so that they become human readable (showing us the number as a date string).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you start with a datetime value (a number representing the seconds since...) and you only want to print the time part then you could use format TODw.d&lt;/P&gt;&lt;P&gt;If you actually want to change the internal value from a SAS datetime to a time value then use timepart() to convert the number and then use a time format like time8. for printing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;;&lt;BR /&gt;&amp;nbsp; var='12aug2012:09:08:07'dt;&lt;BR /&gt;&amp;nbsp; put var= var= tod.;&lt;BR /&gt;&amp;nbsp; var='09:08:07't;&lt;BR /&gt;&amp;nbsp; put var= var= time8.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;&amp;nbsp; dt='12aug2012:09:08:07'dt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; select dt format=best32., dt format=datetime., dt format=tod.&lt;BR /&gt;&amp;nbsp; from have;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 09:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/proc-sql-date-type-convertion/m-p/78454#M683</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-07-31T09:23:54Z</dc:date>
    </item>
  </channel>
</rss>

