<?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 import time of hh:mm:ss AM in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128970#M260462</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should be able to read that with TIME. informat.&lt;/P&gt;&lt;P&gt;Try it this way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards dsd dlm=',' truncover ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat date yymmdd10. time time11. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date time;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date date9. time time8. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put date time;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;2005.06.28,00:00&lt;/P&gt;&lt;P&gt;2005.06.29,1:00&lt;/P&gt;&lt;P&gt;2005.06.30,5:00&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some things check if does not work for you.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Not using the TRUNCOVER option on the INFILE statement might what is tripping you up since your actual time values are much shorter than 11 characters.&lt;/LI&gt;&lt;LI&gt;Are there "invisible" characters after the time value on the line?&amp;nbsp; Add the LIST statement after the INPUT statement and SAS will display what is in the file. If there are unprintable characters in a line it will display the hexadecimal values for all of&amp;nbsp; the characters in the line. &lt;/LI&gt;&lt;LI&gt;If your SAS is running on Unix and the file was generated on a PC then you might have carriage return character at the end of the line that is making the time string invalid.&amp;nbsp; You can fix that by adding TERMSTR=CRLF to the INFILE statement OR by changing the delimiter from ',' to '2C0D'x (hex codes for comma and carriage return).&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Sep 2013 17:13:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2013-09-04T17:13:02Z</dc:date>
    <item>
      <title>How to import time of hh:mm:ss AM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128965#M260457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;I have a scv file with time of the format hh:mm:ss AM. I try different format but still fail to import it to SAS.&lt;/P&gt;&lt;P&gt;All the time, missing data for the whole column.&lt;/P&gt;&lt;P&gt;Any help is very much appreciated.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data&lt;/P&gt;&lt;P&gt;2006.01.30 12:00:00 AM&lt;/P&gt;&lt;P&gt;2006.12.30 12:00:00 AM&lt;/P&gt;&lt;P&gt;2006.12.25 12:00:00 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I use right now is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data originaldata;&lt;/P&gt;&lt;P&gt;infile 'C:\test.csv'&lt;/P&gt;&lt;P&gt; delimiter=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input date :yymmdd8. time ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format date yymmdd8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format time ___________;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 15:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128965#M260457</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2013-09-04T15:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to import time of hh:mm:ss AM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128966#M260458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The TIME informat will read the AM/PM, if you tell it to read enough characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date yymmdd10. time time11. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date date9. time time8. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put date time;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;2006.01.30 12:00:00 AM&lt;/P&gt;&lt;P&gt;2006.12.30 11:00:00 PM&lt;/P&gt;&lt;P&gt;2006.12.25 12:00:00 PM&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 16:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128966#M260458</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-04T16:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to import time of hh:mm:ss AM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128967#M260459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Tom.&lt;/P&gt;&lt;P&gt;When I try your code as below, it still doesn't work. All missing on Time column.&lt;/P&gt;&lt;P&gt;One thing in csv file is that: the time appear on screen is 0:00 for 12:00:00 AM, 1:00 for 1:00:00 AM. I see the full minutes and second (1:00:00 AM) when I click on that cell.&lt;/P&gt;&lt;P&gt;So I don't know if it is something that cause my trouble.&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data originaldata;&lt;/P&gt;&lt;P&gt;infile 'C:\test.csv'&lt;/P&gt;&lt;P&gt; delimiter=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input date :yymmdd8. time time11.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format date yymmdd8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format time&amp;nbsp; time8.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 16:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128967#M260459</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2013-09-04T16:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to import time of hh:mm:ss AM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128968#M260460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CSV files do not have "cells".&amp;nbsp; Are you sure that it is two fields in the CSV file?&amp;nbsp; That is, do you see a comma between the date and time strings?&amp;nbsp; If you are having trouble seeing the actual text of the CSV then open it in the SAS editor or some other text editor or add a LIST statement to your data step..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might need to read it as a character variable and then generate the date and time from that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards dsd dlm=',' truncover ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input dt :$22. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; date = input(scan(dt,1,' '),yymmdd10.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; time = input(substr(dt,length(scan(dt,1,' '))+2),time11.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date date9. time time8. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put date time;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;2006.01.30 12:00:00 AM&lt;/P&gt;&lt;P&gt;2006.12.30 11:00:00 PM&lt;/P&gt;&lt;P&gt;2006.12.25 12:00:00 PM&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 16:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128968#M260460</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-04T16:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to import time of hh:mm:ss AM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128969#M260461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just get back and check.&lt;/P&gt;&lt;P&gt;The file type is: Microsoft Excel Comma Separated Value File.&lt;/P&gt;&lt;P&gt;When I open it, it opens in Excel and therefore I see the&lt;/P&gt;&lt;P&gt;" time appear on screen is 0:00 for 12:00:00 AM, 1:00 for 1:00:00 AM. I see the full minutes and second (1:00:00 AM) when I click on that cell."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To check if it has comma, I right click the file and chose to OPEN with Notepad. Then the data look like that.&lt;/P&gt;&lt;P&gt;So look like it depends on the software I use to open, I see different things.&lt;/P&gt;&lt;P&gt;2005.06.28,00:00&lt;/P&gt;&lt;P&gt;2005.06.29,1:00&lt;/P&gt;&lt;P&gt;2005.06.30,5:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case what should I do?&lt;/P&gt;&lt;P&gt;Thank you, Tom.&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 16:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128969#M260461</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2013-09-04T16:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to import time of hh:mm:ss AM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128970#M260462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should be able to read that with TIME. informat.&lt;/P&gt;&lt;P&gt;Try it this way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards dsd dlm=',' truncover ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat date yymmdd10. time time11. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date time;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date date9. time time8. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put date time;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;2005.06.28,00:00&lt;/P&gt;&lt;P&gt;2005.06.29,1:00&lt;/P&gt;&lt;P&gt;2005.06.30,5:00&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some things check if does not work for you.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Not using the TRUNCOVER option on the INFILE statement might what is tripping you up since your actual time values are much shorter than 11 characters.&lt;/LI&gt;&lt;LI&gt;Are there "invisible" characters after the time value on the line?&amp;nbsp; Add the LIST statement after the INPUT statement and SAS will display what is in the file. If there are unprintable characters in a line it will display the hexadecimal values for all of&amp;nbsp; the characters in the line. &lt;/LI&gt;&lt;LI&gt;If your SAS is running on Unix and the file was generated on a PC then you might have carriage return character at the end of the line that is making the time string invalid.&amp;nbsp; You can fix that by adding TERMSTR=CRLF to the INFILE statement OR by changing the delimiter from ',' to '2C0D'x (hex codes for comma and carriage return).&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 17:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128970#M260462</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-04T17:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to import time of hh:mm:ss AM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128971#M260463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your help.&lt;/P&gt;&lt;P&gt;It works nicely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 13:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-time-of-hh-mm-ss-AM/m-p/128971#M260463</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2013-09-10T13:59:30Z</dc:date>
    </item>
  </channel>
</rss>

