<?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: Import number as time in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58291#M16296</link>
    <description>For more structured support, use the HMS function after reading up the components of the hour and minute portion - example below:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
input hh 2. mm 2.;&lt;BR /&gt;
time = hms(hh,mm,0);&lt;BR /&gt;
put time= time5. ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
2359&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Fri, 24 Jul 2009 02:14:29 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-07-24T02:14:29Z</dc:date>
    <item>
      <title>Import number as time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58289#M16294</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I am using SAS 9.1 and importing a .txt file using infile and input statements.  I am then exporting the file to an MS-Access database.&lt;BR /&gt;
&lt;BR /&gt;
I've got everything figured out except the time fields.  Each time field in the file is in a time increment of a 24 hour clock but without the colon i.e. 2130, 1055, 1544.  How do I import so that SAS recognizes it as a time?  What format do I then use upon export?  &lt;BR /&gt;
&lt;BR /&gt;
Thanks for any and all assistance.</description>
      <pubDate>Thu, 23 Jul 2009 23:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58289#M16294</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2009-07-23T23:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Import number as time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58290#M16295</link>
      <description>No std informat i think to read such a time. You have to tweak it a bit.&lt;BR /&gt;
&lt;BR /&gt;
 x='2130';&lt;BR /&gt;
 sastime=input(x,2.)*3600+input(substr(x,3,2),2.)*60;&lt;BR /&gt;
 or&lt;BR /&gt;
 sastime=input( substr(x,1,2)||':'||substr(x,3,2)||':00', time.);&lt;BR /&gt;
&lt;BR /&gt;
The export format will depend on what Access wants. &lt;B&gt;time.&lt;/B&gt; or &lt;B&gt;hhmm.&lt;/B&gt; would seem adequate.</description>
      <pubDate>Fri, 24 Jul 2009 00:15:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58290#M16295</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-07-24T00:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Import number as time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58291#M16296</link>
      <description>For more structured support, use the HMS function after reading up the components of the hour and minute portion - example below:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
input hh 2. mm 2.;&lt;BR /&gt;
time = hms(hh,mm,0);&lt;BR /&gt;
put time= time5. ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
2359&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 24 Jul 2009 02:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58291#M16296</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-24T02:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Import number as time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58292#M16297</link>
      <description>Indeed, Scott's suggestion to let the hms function do the calculation is a bit tidier. You now have:&lt;BR /&gt;
&lt;BR /&gt;
x='2130';&lt;BR /&gt;
sastime=input(x,2.)*3600+input(substr(x,3,2),2.)*60;&lt;BR /&gt;
or&lt;BR /&gt;
sastime=hms( input(x,2.), input(substr(x,3,2),2.), 0);&lt;BR /&gt;
or&lt;BR /&gt;
sastime=input( substr(x,1,2)||':'||substr(x,3,2)||':00', time.);&lt;BR /&gt;
&lt;BR /&gt;
So many ways with sas!  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sun, 26 Jul 2009 21:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58292#M16297</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-07-26T21:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Import number as time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58293#M16298</link>
      <description>But if I have a :&lt;BR /&gt;
&lt;BR /&gt;
105   (time: 01:05)&lt;BR /&gt;
&lt;BR /&gt;
how can I do?</description>
      <pubDate>Wed, 10 Mar 2010 17:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58293#M16298</guid>
      <dc:creator>Ken_oy</dc:creator>
      <dc:date>2010-03-10T17:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Import number as time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58294#M16299</link>
      <description>well, it will be more easier in excel&lt;BR /&gt;
change it in excel 105-&amp;gt; 0105</description>
      <pubDate>Wed, 10 Mar 2010 17:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58294#M16299</guid>
      <dc:creator>Ken_oy</dc:creator>
      <dc:date>2010-03-10T17:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Import number as time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58295#M16300</link>
      <description>Forum posting Suggestion: next time create a new post as you being the AUTHOR, and paste a link if needed back to some forum archive reference.  &lt;BR /&gt;
&lt;BR /&gt;
With SAS 9.2, you have the ISO 8601 INFORMAT B8601TM demonstrated below.&lt;BR /&gt;
&lt;BR /&gt;
Otherwise, you will need to separate the minute- and hour-portion and use the HMS function to derive a SAS numeric TIME variable.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
68   data _null_;&lt;BR /&gt;
69   c_hmm = '105';&lt;BR /&gt;
70   n_hmm = input(c_hmm,best.);&lt;BR /&gt;
71   c_hhmm = put(n_hmm,z6.);&lt;BR /&gt;
72   n_hmm_sec = input(c_hhmm,b8601tm.);&lt;BR /&gt;
73   format n_hmm_sec time8.;&lt;BR /&gt;
74   putlog _all_;&lt;BR /&gt;
75   run;&lt;BR /&gt;
&lt;BR /&gt;
c_hmm=105 n_hmm=105 c_hhmm=000105 n_hmm_sec=0:01:05 _ERROR_=0 _N_=1&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.2 Language Reference, Informats by Category&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a001239776.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a001239776.htm&lt;/A&gt;

Message was edited by: sbb</description>
      <pubDate>Wed, 10 Mar 2010 17:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-number-as-time/m-p/58295#M16300</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-10T17:43:15Z</dc:date>
    </item>
  </channel>
</rss>

