<?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: HH:MM:SS time format from AM/PM data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/693161#M211322</link>
    <description>&lt;PRE&gt;data want ;
time="04:56 PM"t;output;
time="11:59 PM"t;output;
time="12:00 PM"t;output;
time="12:51 PM"t;output;
time="00:00 AM"t;output;
time="10:19 AM"t;output;
time="01:19 AM"t;output;
format time tod.;
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Oct 2020 13:10:11 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-10-21T13:10:11Z</dc:date>
    <item>
      <title>HH:MM:SS time format from AM/PM data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/692872#M211165</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How shall I convert below mentioned data into 24 hours format of hh:mm:ss (char).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want ;&lt;BR /&gt;time="04:56 PM";output;&lt;BR /&gt;time="11:59 PM";output;&lt;BR /&gt;time="12:00 PM";output;&lt;BR /&gt;time="12:51 PM";output;&lt;BR /&gt;time="00:00 AM";output;&lt;BR /&gt;time="10:19 AM";output;&lt;BR /&gt;time="01:19 AM";output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 14:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/692872#M211165</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-10-20T14:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: HH:MM:SS time format from AM/PM data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/692874#M211167</link>
      <description>&lt;P&gt;Use the TIME informat to convert those strings to actual time values (number of seconds) and then use the TOD format to convert it back to a string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input time $8. ;
cards;
04:56 PM
11:59 PM
12:00 PM
12:51 PM
00:00 AM
10:19 AM
01:19 AM
;

data want;
  set have;
  time2=put(input(time,time8.),tod8.);
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs      time       time2

 1     04:56 PM    16:56:00
 2     11:59 PM    23:59:00
 3     12:00 PM    12:00:00
 4     12:51 PM    12:51:00
 5     00:00 AM    00:00:00
 6     10:19 AM    10:19:00
 7     01:19 AM    01:19:00&lt;/PRE&gt;
&lt;P&gt;But it might be easier to deal with the values if you left them as numeric time values instead of strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  time2=input(time,time8.) ;
  format time2 tod8. ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Oct 2020 14:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/692874#M211167</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-20T14:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: HH:MM:SS time format from AM/PM data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/692879#M211170</link>
      <description>Thank you so much for your quick reply. Its helpful for me. My approch was too long and also data was not proper.&lt;BR /&gt;&lt;BR /&gt; data have ;&lt;BR /&gt;   set want;&lt;BR /&gt;   hh = scan(time,1,":") ;&lt;BR /&gt;   mm = substr(time,4,2);&lt;BR /&gt;   am_pm = scan(time,-1," ");&lt;BR /&gt;   if hh ne "12" and am_pm = "PM" then  hours = (hh + 12);&lt;BR /&gt;  else if am_pm ne "PM" then hours = hh;&lt;BR /&gt;  else if hh in ("00" "12") then hours=hh;&lt;BR /&gt;  cm_time= cat(strip(hours) ||":"||strip(mm)||":00");&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you again.</description>
      <pubDate>Tue, 20 Oct 2020 14:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/692879#M211170</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-10-20T14:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: HH:MM:SS time format from AM/PM data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/693161#M211322</link>
      <description>&lt;PRE&gt;data want ;
time="04:56 PM"t;output;
time="11:59 PM"t;output;
time="12:00 PM"t;output;
time="12:51 PM"t;output;
time="00:00 AM"t;output;
time="10:19 AM"t;output;
time="01:19 AM"t;output;
format time tod.;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Oct 2020 13:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/693161#M211322</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-10-21T13:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: HH:MM:SS time format from AM/PM data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/693383#M211400</link>
      <description>Thank you for the solution..</description>
      <pubDate>Thu, 22 Oct 2020 04:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HH-MM-SS-time-format-from-AM-PM-data/m-p/693383#M211400</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2020-10-22T04:35:58Z</dc:date>
    </item>
  </channel>
</rss>

