<?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 can I round time stamp to the bottom hour in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376440#M90362</link>
    <description>&lt;P&gt;I meant to &amp;nbsp;convert '06:25' and '06:35' to '06:00'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-footer"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-left lia-quilt-column-footer-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-notify lia-component-report-abuse"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-message-statistics lia-component-position-in-thread"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 17 Jul 2017 09:36:03 GMT</pubDate>
    <dc:creator>AMFR</dc:creator>
    <dc:date>2017-07-17T09:36:03Z</dc:date>
    <item>
      <title>How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376138#M90245</link>
      <description>&lt;P&gt;Hello SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a numeric datetime variable like this 18AUG2015:&lt;STRONG&gt;16:25:00&lt;/STRONG&gt;. I&amp;nbsp;want to round this to bottom hour.&amp;nbsp;Output should be like 18AUG2015:&lt;STRONG&gt;16:00:00. &lt;/STRONG&gt;How can i do this. Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 19:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376138#M90245</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2017-07-14T19:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376144#M90249</link>
      <description>&lt;P&gt;INTNX function with alignment 'B' for begin:&lt;/P&gt;
&lt;PRE&gt;data example;
   dt = '18AUG2015:16:25:00'dt;
   y  = intnx('hour',dt,0,'B');
   format y datetime.;
   put y= datetime.;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jul 2017 19:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376144#M90249</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-14T19:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376168#M90255</link>
      <description>Thanks ballardw for your reply. I tried with your piece of code. There is&lt;BR /&gt;one problem, I have a huge dataset and with your code SAS is running from&lt;BR /&gt;last 5 minutes. I can see in the log that it worked and created&lt;BR /&gt;the timestamp variable the way I wanted. But it is running and running and&lt;BR /&gt;not producing output in the results window.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Fri, 14 Jul 2017 22:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376168#M90255</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2017-07-14T22:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376170#M90256</link>
      <description>&lt;P&gt;Remove the PUT statement. There will be no OUTPUT in the results window because you're creating a data set and there is no 'results'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use the ROUND function, but I doubt that will help. Datetime are stored in seconds, so the nearest hour is the nearest,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;60seconds*60minutes=3600 seconds.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Time = round(time_var, 3600);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jul 2017 22:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376170#M90256</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-14T22:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376175#M90258</link>
      <description>&lt;P&gt;Thanks Reeza.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I tried round function but it didnt produce the desired results. But after removing the PUT statement i got the desired results. I do not why i was expexting output in the results window in a data step, that was such a lame question. I think I am lost. Thanks again&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 23:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376175#M90258</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2017-07-14T23:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376208#M90269</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120524"&gt;@AMFR&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Reeza.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I tried round function but it didnt produce the desired results. But after removing the PUT statement i got the desired results. I do not why i was expexting output in the results window in a data step, that was such a lame question. I think I am lost. Thanks again&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;AND the original reason I had PUT was for demostration. I expected you to only use the function as needed in your actual code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe the issue with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s suggestion was using ROUND which would round up when seconds exceed 1800 with in any hour&amp;nbsp; interval. Floor might work but you'd need to do more arithemetic to get the right trim and with the existing solution likely not worth headache.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 05:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376208#M90269</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-15T05:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376245#M90279</link>
      <description>Thanks for the details, I appreciate it</description>
      <pubDate>Sat, 15 Jul 2017 14:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376245#M90279</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2017-07-15T14:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376254#M90285</link>
      <description>&lt;P&gt;Not sure what "bottom hour" means. Does that mean when the minute hand is pointing down at the 6? &amp;nbsp;Do you want to convert '06:25' and '06:35' to '06:00' or '06:30'?&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 16:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376254#M90285</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-15T16:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376440#M90362</link>
      <description>&lt;P&gt;I meant to &amp;nbsp;convert '06:25' and '06:35' to '06:00'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-footer"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-left lia-quilt-column-footer-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-notify lia-component-report-abuse"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-message-statistics lia-component-position-in-thread"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 17 Jul 2017 09:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/376440#M90362</guid>
      <dc:creator>AMFR</dc:creator>
      <dc:date>2017-07-17T09:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/502291#M134068</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Hi.&lt;/P&gt;&lt;P&gt;My value:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;18Aug2018 12:31:00&lt;/P&gt;&lt;P&gt;17Aug2018 01:28:00&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What If i want to set if minutes =&amp;gt; 30 then round up + 1 hour.&lt;/P&gt;&lt;P&gt;Otherwise, use your sample code to set to 00 minutes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently your code always set minutes to 00 regardless of the minutes.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 01:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/502291#M134068</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-10-08T01:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/502293#M134069</link>
      <description>&lt;P&gt;If you actually did want to round then use the ROUND() function.&amp;nbsp; Since DATETIME values are seconds you can use the number of seconds in an hour as the second argument to ROUND().&amp;nbsp; So just use a time literal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;round(dt,'01:00't)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;105   data example;
106     do dt = '18AUG2015:16:25:00'dt,'18AUG2015:16:35:00'dt ;
107      y  = intnx('hour',dt,0,'B');
108      z = round(dt,'01:00't);
109      format dt y z datetime20.;
110      put (_all_) (=);
111     end;
112   run;

dt=18AUG2015:16:25:00 y=18AUG2015:16:00:00 z=18AUG2015:16:00:00
dt=18AUG2015:16:35:00 y=18AUG2015:16:00:00 z=18AUG2015:17:00:00
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 01:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/502293#M134069</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-08T01:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I round time stamp to the bottom hour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/502305#M134075</link>
      <description>&lt;P&gt;I havent reach my workdesk yet.&lt;/P&gt;&lt;P&gt;Assuming i want it to only round up or down for 30mins.&lt;/P&gt;&lt;P&gt;Changing from&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;round&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dt&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token datetime number"&gt;'01:00't&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;round&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;dt&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token datetime number"&gt;'00:30't&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;will do the trick right?&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 02:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-round-time-stamp-to-the-bottom-hour/m-p/502305#M134075</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-10-08T02:48:13Z</dc:date>
    </item>
  </channel>
</rss>

