<?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 do I subtract times in 24 hr format in the form hh:mm? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860170#M339833</link>
    <description>&lt;P&gt;The input function in SAS converts character strings into numeric. If time1 is character, then use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;time1_numeric=input(time1,time5.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Feb 2023 14:09:28 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-02-22T14:09:28Z</dc:date>
    <item>
      <title>How do I subtract times in 24 hr format in the form hh:mm?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860164#M339828</link>
      <description>&lt;P&gt;Hi, I'm trying to find the difference between time2 from time1 in the following data set.&lt;/P&gt;
&lt;P&gt;Time1, Time2 are character variables. I'm having a difficult time trying to subtract the different times.&lt;/P&gt;
&lt;P&gt;The difference should be in the unit of hours.&lt;/P&gt;
&lt;P&gt;ex: So if the difference is 30 minutes more, between time2 and time1, the value should be &lt;STRONG&gt;0.50&lt;/STRONG&gt; (2 decimal places extended maximum with a leading 0). Or if the difference is 45 minutes less between time2 and time1, the value should be &lt;STRONG&gt;-0.75.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
infile datalines dsd dlm=",";
	input day $ time1 $ time2 $;
datalines;
day1, 08:25, 08:30
day2, 09:15, 09:45
day3, 10:05, 09:45
day4, 14:05, 14:10
day5, 15:10, 14:30
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2023 13:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860164#M339828</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2023-02-22T13:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I subtract times in 24 hr format in the form hh:mm?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860168#M339831</link>
      <description>&lt;P&gt;Time values (and also date values and date-time values) should be numeric, not character! Then, differences are found by subtraction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
infile datalines dsd dlm=",";
	input day $ time1 time2;
    informat time1 time2 time5.;
    format time1 time2 time5.;
datalines;
day1, 08:25, 08:30
day2, 09:15, 09:45
day3, 10:05, 09:45
day4, 14:05, 14:10
day5, 15:10, 14:30
;
run;

data want;
    set have;
    difference=time2-time1;
    hours=difference/3600;
    format difference time5.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 14:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860168#M339831</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-22T14:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I subtract times in 24 hr format in the form hh:mm?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860169#M339832</link>
      <description>&lt;P&gt;Thanks, for the reply and answer. The data was given to me in character. I didn't know if there was a function i didn't know about that converts into numeric easily besides using input().&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 14:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860169#M339832</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2023-02-22T14:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I subtract times in 24 hr format in the form hh:mm?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860170#M339833</link>
      <description>&lt;P&gt;The input function in SAS converts character strings into numeric. If time1 is character, then use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;time1_numeric=input(time1,time5.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2023 14:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-subtract-times-in-24-hr-format-in-the-form-hh-mm/m-p/860170#M339833</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-22T14:09:28Z</dc:date>
    </item>
  </channel>
</rss>

