<?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 break total records into intervals of 30 minutes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648381#M194202</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9440"&gt;@vicky07&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your reply. Quick follow up questions, how do i change my date to&amp;nbsp;05/16/2020 format in the final output. Also, I want to display current date in my output instead of using hard coded date.&amp;nbsp; &amp;nbsp;Cold you please help with changing the date format and adding current date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have2;
    group=floor((_n_-1)/77);
    today=today();
    hour='09:00't+1800*group;
    date_plus_time=catx(' ',put(today,mmddyys10.),put(hour,time5.));
    drop today hour group;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 17 May 2020 11:21:01 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-05-17T11:21:01Z</dc:date>
    <item>
      <title>How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648302#M194167</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sample dataset to which I need to append current date and time(hh:mm) with interval of 30 minutes.&amp;nbsp; The challenge is to break the total records into groups of 30 minutes between 9 am and 3 pm. So for example I have 1000 records in my data and I want to randomly take&amp;nbsp; ~77(1000/13)&amp;nbsp; and assign&amp;nbsp;05/16/2020 09:00 and the next batch of random 77 would get&amp;nbsp;05/16/2020 09:30 and the next would get&amp;nbsp;05/16/2020 10:00&amp;nbsp; and so on till&amp;nbsp;05/16/2020 15:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Sample data&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Data have;&lt;BR /&gt;do i = 1 to 1000;&lt;BR /&gt;ID = 123 * i;&lt;BR /&gt;ID_time = put(today(),mmddyys10.) ||''||put(time(),hhmm.);&lt;BR /&gt;drop i;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Sample output:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ID ID_time&lt;BR /&gt;123 5/16/2020 9:00&lt;BR /&gt;246 5/16/2020 9:00&lt;BR /&gt;369 5/16/2020 9:00&lt;BR /&gt;492 5/16/2020 9:00&lt;BR /&gt;615 5/16/2020 9:00&lt;BR /&gt;738 5/16/2020 9:00&lt;BR /&gt;861 5/16/2020 9:30&lt;BR /&gt;984 5/16/2020 9:30&lt;BR /&gt;1107 5/16/2020 9:30&lt;BR /&gt;1230 5/16/2020 9:30&lt;BR /&gt;1353 5/16/2020 9:30&lt;BR /&gt;1476 5/16/2020 9:30&lt;BR /&gt;1599 5/16/2020 10:00&lt;BR /&gt;1722 5/16/2020 10:00&lt;BR /&gt;1845 5/16/2020 10:00&lt;BR /&gt;1968 5/16/2020 10:00&lt;BR /&gt;2091 5/16/2020 10:00&lt;BR /&gt;2214 5/16/2020 10:00&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your time and help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2020 15:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648302#M194167</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2020-05-16T15:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648310#M194170</link>
      <description>&lt;P&gt;You would assign random numbers to each ID. Then once that is done, you can assign to the first 77 the date and time 05/16/2020 09:00, and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
    set have;
    y=rand('uniform');
run;
proc sort data=have2;
    by y;
run;
data want;
    set have2;
    group=floor((_n_-1)/77);
    time = '16MAY2020:09:00:00'dt+30*60*group;
    format time datetime16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2020 15:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648310#M194170</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-16T15:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648359#M194189</link>
      <description>&lt;P&gt;Thank you for your reply. Quick follow up questions, how do i change my date to&amp;nbsp;05/16/2020 format in the final output. Also, I want to display current date in my output instead of using hard coded date.&amp;nbsp; &amp;nbsp;Cold you please help with changing the date format and adding current date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 03:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648359#M194189</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2020-05-17T03:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648361#M194190</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV id="statug_surveyselect000025" class="aa-section"&gt;
&lt;DIV&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_surveyselect_overview.htm&amp;amp;docsetVersion=14.2&amp;amp;locale=en" target="_self"&gt;The SURVEYSELECT Procedure&lt;/A&gt;&amp;nbsp;provides a variety of methods for selecting probability-based random samples.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV id="statug_surveyselect000025" class="aa-section"&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data have;
  do id = 1 to 1000;
    output;
  end;
run;

proc surveyselect noprint data=have out=groups groups=13;
run;

data want;
  set groups;
  timestamp = dhms(today(),8,30,0) + groupId * 1800;
  format timestamp dateAMPM.;
run;

proc freq data=want;
  table timestamp;
run;
&lt;/PRE&gt;
&lt;P&gt;Output&lt;/P&gt;
&lt;DIV id="tinyMceEditorRichardADeVenezia_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="freq2.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39534iD4E11D26355CD75A/image-size/large?v=v2&amp;amp;px=999" role="button" title="freq2.png" alt="freq2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 17 May 2020 03:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648361#M194190</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-05-17T03:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648381#M194202</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9440"&gt;@vicky07&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your reply. Quick follow up questions, how do i change my date to&amp;nbsp;05/16/2020 format in the final output. Also, I want to display current date in my output instead of using hard coded date.&amp;nbsp; &amp;nbsp;Cold you please help with changing the date format and adding current date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have2;
    group=floor((_n_-1)/77);
    today=today();
    hour='09:00't+1800*group;
    date_plus_time=catx(' ',put(today,mmddyys10.),put(hour,time5.));
    drop today hour group;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 May 2020 11:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648381#M194202</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-17T11:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648386#M194207</link>
      <description>Just being picky, aren't there 12 intervals whose time ranges fall BETWEEN 9AM and 3PM.  The 13th, or 3:00PM one ends at 3:30</description>
      <pubDate>Sun, 17 May 2020 11:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648386#M194207</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-05-17T11:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648446#M194244</link>
      <description>This is perfect. Thank you very much!!!</description>
      <pubDate>Sun, 17 May 2020 22:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648446#M194244</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2020-05-17T22:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648447#M194245</link>
      <description>Thank you very much,good to learn survey select method.</description>
      <pubDate>Sun, 17 May 2020 22:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648447#M194245</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2020-05-17T22:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do i break total records into intervals of 30 minutes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648448#M194246</link>
      <description>You are right, the 3.00 pm one ends at 3.30.</description>
      <pubDate>Sun, 17 May 2020 22:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-break-total-records-into-intervals-of-30-minutes/m-p/648448#M194246</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2020-05-17T22:19:32Z</dc:date>
    </item>
  </channel>
</rss>

