<?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 How do I convert hh:mm (text) into TIME5.2 with INPUT in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/859699#M42320</link>
    <description>&lt;P&gt;Dear reader,&lt;/P&gt;&lt;P&gt;I have a question regarding converting date and time in a text format (Excel) into a separate date and timefield. I do not want to touch or modify the Excel,&amp;nbsp; the date and time are a Text field, e.g. 2021-02-13T09:46.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I manage to take out the date part and convert it to a DATE9. format.&lt;/P&gt;&lt;P&gt;But as for the time this does not work. Is there a solution how to best get my results?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want&amp;nbsp;SAMPDT_CC as DATE9,&amp;nbsp; which works&lt;/P&gt;&lt;P&gt;and SAMPTM_CC as TIME5.2 and I cannot manage to get this..&lt;/P&gt;&lt;P&gt;Here is&amp;nbsp; code (also uploaded)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC IMPORT&lt;BR /&gt;DATAFILE="C:\.......\SAMPLEDATETIME.xlsx"&lt;BR /&gt;OUT=BIOMCC&lt;BR /&gt;DBMS=xlsx&lt;BR /&gt;REPLACE;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA BIOMCC2;&lt;BR /&gt;SET BIOMCC;&lt;BR /&gt;DT=SUBSTR(SAMPLE_DATE,1,10);&lt;BR /&gt;TM=SUBSTR(SAMPLE_DATE,12,5);&lt;BR /&gt;DROP SAMPLE_DATE;&lt;BR /&gt;SAMPDT_CC=INPUT(DT,YYMMDD10.);&lt;BR /&gt;SAMPTM_CC=INPUT(TM,HHMM5.2);&lt;BR /&gt;FORMAT SAMPDT_CC DATE9.;&lt;BR /&gt;FORMAT SAMPTM_CC TIME5.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for support!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;</description>
    <pubDate>Mon, 20 Feb 2023 13:03:17 GMT</pubDate>
    <dc:creator>JohanK</dc:creator>
    <dc:date>2023-02-20T13:03:17Z</dc:date>
    <item>
      <title>How do I convert hh:mm (text) into TIME5.2 with INPUT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/859699#M42320</link>
      <description>&lt;P&gt;Dear reader,&lt;/P&gt;&lt;P&gt;I have a question regarding converting date and time in a text format (Excel) into a separate date and timefield. I do not want to touch or modify the Excel,&amp;nbsp; the date and time are a Text field, e.g. 2021-02-13T09:46.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I manage to take out the date part and convert it to a DATE9. format.&lt;/P&gt;&lt;P&gt;But as for the time this does not work. Is there a solution how to best get my results?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want&amp;nbsp;SAMPDT_CC as DATE9,&amp;nbsp; which works&lt;/P&gt;&lt;P&gt;and SAMPTM_CC as TIME5.2 and I cannot manage to get this..&lt;/P&gt;&lt;P&gt;Here is&amp;nbsp; code (also uploaded)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC IMPORT&lt;BR /&gt;DATAFILE="C:\.......\SAMPLEDATETIME.xlsx"&lt;BR /&gt;OUT=BIOMCC&lt;BR /&gt;DBMS=xlsx&lt;BR /&gt;REPLACE;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA BIOMCC2;&lt;BR /&gt;SET BIOMCC;&lt;BR /&gt;DT=SUBSTR(SAMPLE_DATE,1,10);&lt;BR /&gt;TM=SUBSTR(SAMPLE_DATE,12,5);&lt;BR /&gt;DROP SAMPLE_DATE;&lt;BR /&gt;SAMPDT_CC=INPUT(DT,YYMMDD10.);&lt;BR /&gt;SAMPTM_CC=INPUT(TM,HHMM5.2);&lt;BR /&gt;FORMAT SAMPDT_CC DATE9.;&lt;BR /&gt;FORMAT SAMPTM_CC TIME5.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for support!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 13:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/859699#M42320</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-02-20T13:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert hh:mm (text) into TIME5.2 with INPUT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/859700#M42321</link>
      <description>&lt;P&gt;Most of us will not download Excel files, as it is a security risk. Please show us a portion of the SAS data set (not the Excel file) so we can see the date and time values that you are having trouble with.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 13:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/859700#M42321</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-20T13:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert hh:mm (text) into TIME5.2 with INPUT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/859729#M42324</link>
      <description>&lt;P&gt;So assuming that the cells in the XLSX file are TEXT so that PROC IMPORT creates a character variable with values like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input sample_date $15. ;
cards;
2021-02-13T09:46
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can convert that string directly to a DATETIME value using the E8601DT informat. (To use the B8601DT informat&amp;nbsp; just remove the punctuation.)&lt;/P&gt;
&lt;P&gt;You can convert that string into DATE and TIME values by parsing around the T and using the YYMMDD and TIME informats.&amp;nbsp; The HHMM informat is for strings without the punctuation.&amp;nbsp; To display the leading zero on times before 10 am use the TOD format instead of the TIME format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  dt = input(sample_date,e8601dt.);
  date = input(sample_date,yymmdd10.);
  time = input(scan(sample_date,2,'T'),time5.);
  format dt datetime19. date date9. time tod5. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs      sample_date                        dt         date     time

 1     2021-02-13T09:46     13FEB2021:09:46:00    13FEB2021    09:46
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 15:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/859729#M42324</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-20T15:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert hh:mm (text) into TIME5.2 with INPUT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/860087#M42337</link>
      <description>&lt;P&gt;Thank you so much Tom, it works!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 07:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/860087#M42337</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-02-22T07:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert hh:mm (text) into TIME5.2 with INPUT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/860088#M42338</link>
      <description>&lt;P&gt;Hello Paigemiller, thanks. I have a solution&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 07:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-convert-hh-mm-text-into-TIME5-2-with-INPUT/m-p/860088#M42338</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-02-22T07:05:01Z</dc:date>
    </item>
  </channel>
</rss>

