<?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: change numeric values to sas time format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385775#M92324</link>
    <description>&lt;P&gt;Probably a slicker way, but this should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input have;
timepad =  strip(put(have, z4.));
want = hms(substr(timepad, 1, 2), substr(timepad, 3, 2), 0);
format want time5.;
datalines;
120
2130
10
1128
23
50
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Aug 2017 21:22:19 GMT</pubDate>
    <dc:creator>collinelliot</dc:creator>
    <dc:date>2017-08-04T21:22:19Z</dc:date>
    <item>
      <title>change numeric values to sas time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385771#M92323</link>
      <description>&lt;P&gt;HI!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have numeric values in time variables using military time.&amp;nbsp; When I try the HHMM. the output is not correct&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My data values look like this&lt;/P&gt;
&lt;TABLE width="108"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="108"&gt;Time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;120&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2130&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1128&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want to look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="227"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="108"&gt;Time&lt;/TD&gt;
&lt;TD width="119"&gt;Want&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;120&lt;/TD&gt;
&lt;TD&gt;01:20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2130&lt;/TD&gt;
&lt;TD&gt;21:30&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;TD&gt;00:10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1128&lt;/TD&gt;
&lt;TD&gt;11:28&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;23&lt;/TD&gt;
&lt;TD&gt;00:23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;50&lt;/TD&gt;
&lt;TD&gt;00:50&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestion appreciated!!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 21:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385771#M92323</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2017-08-04T21:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: change numeric values to sas time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385775#M92324</link>
      <description>&lt;P&gt;Probably a slicker way, but this should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input have;
timepad =  strip(put(have, z4.));
want = hms(substr(timepad, 1, 2), substr(timepad, 3, 2), 0);
format want time5.;
datalines;
120
2130
10
1128
23
50
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Aug 2017 21:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385775#M92324</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-08-04T21:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: change numeric values to sas time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385776#M92325</link>
      <description>&lt;P&gt;Before you can use a time format, you have to convert the numbers to &lt;EM&gt;date-time&lt;/EM&gt; &lt;EM&gt;numbers&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;time2=hms(floor(time/100),mod(time,100),0); /* Convert time to hours and minutes using the hms function */
format time2 hhmm5.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 21:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385776#M92325</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-04T21:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: change numeric values to sas time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385779#M92326</link>
      <description>&lt;P&gt;Mine isn't smart, but fun though-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input time;&lt;BR /&gt;datalines;&lt;BR /&gt;120&lt;BR /&gt;2130&lt;BR /&gt;10&lt;BR /&gt;1128&lt;BR /&gt;23&lt;BR /&gt;50&lt;BR /&gt;;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;new_time=cats(reverse(substr(reverse(time),3)),':',substr(time,length(time)-1));&lt;BR /&gt;if length(new_time)=3 then new_time=cats('00',new_time);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 21:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-numeric-values-to-sas-time-format/m-p/385779#M92326</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-04T21:39:28Z</dc:date>
    </item>
  </channel>
</rss>

