<?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: minute() function gives values off by 1 minute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419440#M103139</link>
    <description>&lt;P&gt;Sorry forgot to mention. start_of_wake_time and end_of_wake_time are already in numeric values with format of time8.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2017 02:07:45 GMT</pubDate>
    <dc:creator>chingweelim</dc:creator>
    <dc:date>2017-12-08T02:07:45Z</dc:date>
    <item>
      <title>minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419435#M103136</link>
      <description>&lt;P&gt;I am puzzled as to why some of the results given by the minute() function are off by 1 minute during data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the have data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture 2.PNG" style="width: 112px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17084i0002635D62EB6F7E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture 2.PNG" alt="Picture 2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code and the want data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
start_wake_minute = minute(Start_of_Wake_Time);
end_wake_minute = minute(End_of_Wake_Time);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture 1.PNG" style="width: 514px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17083i22C8AA06B1188015/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture 1.PNG" alt="Picture 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see in the first row, 'end_wake_minute' shows 59 when it is supposed to be 00. This is the same for the next two rows. The last two rows gave correct values. Am I missing something?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also included 'start_wake_time_num' and 'end_wake_time_num' where they are numeric formats of 'Start of Wake Time' and 'End&lt;SPAN&gt;&amp;nbsp;of Wake Time&lt;/SPAN&gt;' respectively for your reference.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 01:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419435#M103136</guid>
      <dc:creator>chingweelim</dc:creator>
      <dc:date>2017-12-08T01:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419436#M103137</link>
      <description>&lt;P&gt;You didn't provide your input file in the form of a datastep and, my guess, that is where your problem is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming row 2 should have a value of 30, the following does exactly what you showed you wanted:&lt;/P&gt;
&lt;PRE&gt;data have;
  input (start_of_wake_time end_of_wake_time) (time8.);
  cards;
5:00:00 22:00:00
5:00:00 23:30:00
6:00:00 22:00:00
3:10:00 21:08:00
7:00:00 22:10:00
;
data want;
  set have;
  start_wake_minute = minute(Start_of_Wake_Time);
  end_wake_minute = minute(End_of_Wake_Time);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 01:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419436#M103137</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-08T01:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419437#M103138</link>
      <description>&lt;P&gt;Remove the formats and check your data. The underlying data will likely explain the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 02:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419437#M103138</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-08T02:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419440#M103139</link>
      <description>&lt;P&gt;Sorry forgot to mention. start_of_wake_time and end_of_wake_time are already in numeric values with format of time8.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 02:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419440#M103139</guid>
      <dc:creator>chingweelim</dc:creator>
      <dc:date>2017-12-08T02:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419441#M103140</link>
      <description>&lt;P&gt;'start_wake_time_num' and 'end_wake_time_num' are 'start_of_wake_times' and 'end&lt;SPAN&gt;_of_wake_times&lt;/SPAN&gt;' numeric values respectively with the 'time8.' format removed (replaced with 'best12.').&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 02:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419441#M103140</guid>
      <dc:creator>chingweelim</dc:creator>
      <dc:date>2017-12-08T02:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419444#M103142</link>
      <description>&lt;P&gt;And what do they look like?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179204"&gt;@chingweelim&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;'start_wake_time_num' and 'end_wake_time_num' are 'start_of_wake_times' and 'end&lt;SPAN&gt;_of_wake_times&lt;/SPAN&gt;' numeric values respectively with the 'time8.' format removed (replaced with 'best12.').&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 02:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419444#M103142</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-08T02:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419453#M103145</link>
      <description>&lt;P&gt;You can refer to my first post's second table. They seem okay to me.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 02:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419453#M103145</guid>
      <dc:creator>chingweelim</dc:creator>
      <dc:date>2017-12-08T02:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419454#M103146</link>
      <description>&lt;P&gt;Try the following on your data and let us (the forum) know if it produces the result you expect:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  start_wake_minute =minute(Round(Start_of_Wake_Time,hms(0,1,00)));
  end_wake_minute =minute(Round(End_of_Wake_Time,hms(0,1,00)));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 03:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419454#M103146</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-08T03:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419467#M103148</link>
      <description>&lt;P&gt;Brilliant! I tried it and it worked wonders! I am just curious as to why we need to round. The formatted best12. values seems alright to me. Is it because it may have decimal places involved? Just an FYI, I've imported these times from excel. So that could have caused small decimal values to be included while importing?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 03:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419467#M103148</guid>
      <dc:creator>chingweelim</dc:creator>
      <dc:date>2017-12-08T03:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419468#M103149</link>
      <description>&lt;P&gt;No idea without actually seeing the raw data or the data with no format applied but, yes, it could well be because the raw data contained fractions of a second. The code I posted simply rounded the time to the nearest minute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 03:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419468#M103149</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-08T03:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419469#M103150</link>
      <description>&lt;P&gt;The time8..0 format rounds to the nearest minutes.&amp;nbsp; Consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   t='21:59:59.8't;
   put t=time10.1;
   put t=time8.0;
   minute_t=minute(t);
   put minute_t=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which produces:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
t=21:59:59.8
t=22:00:00
minute_t=59
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because the time8. format rounded up, you were unaware that the time value was still in the 59th minute.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 04:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419469#M103150</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-12-08T04:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419470#M103151</link>
      <description>&lt;P&gt;I see. Thank you for the example!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 04:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419470#M103151</guid>
      <dc:creator>chingweelim</dc:creator>
      <dc:date>2017-12-08T04:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419471#M103152</link>
      <description>&lt;P&gt;Thank you so much! I'll keep rounding in mind for future codes.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 04:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419471#M103152</guid>
      <dc:creator>chingweelim</dc:creator>
      <dc:date>2017-12-08T04:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: minute() function gives values off by 1 minute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419620#M103194</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179204"&gt;@chingweelim&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Brilliant! I tried it and it worked wonders! I am just curious as to why we need to round. The formatted best12. values seems alright to me. Is it because it may have decimal places involved? Just an FYI, I've imported these times from excel. So that could have caused small decimal values to be included while importing?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Decimals in a SAS time value are fractions of second.&lt;/P&gt;
&lt;P&gt;Likely Excel is most likely&amp;nbsp;hiding the fractional seconds with a display that only shows whole seconds. Go to the spreadsheet document and change the column to simple numeric with 2 or 3 decimals and examine. I suspect you will see the same decimals as SAS shows. There might be differences if you have enough decimals, more than 10 most likely, that precision of computer storage issues arise.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 16:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/minute-function-gives-values-off-by-1-minute/m-p/419620#M103194</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-08T16:43:14Z</dc:date>
    </item>
  </channel>
</rss>

