<?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: making tick-by-tick data into time interval data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503020#M134349</link>
    <description>I'm sorry. I'm quite new with sas, and I don't think I properly understood what you mean by 'data step showing the output data set I require.'&lt;BR /&gt;The data step you amended above is correct, and I don't see what exactly is it that you are asking?</description>
    <pubDate>Wed, 10 Oct 2018 10:07:06 GMT</pubDate>
    <dc:creator>LzEr23</dc:creator>
    <dc:date>2018-10-10T10:07:06Z</dc:date>
    <item>
      <title>making tick-by-tick data into time interval data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/502991#M134338</link>
      <description>Dear all,&lt;BR /&gt;I asked similar question before but I had to post it again cause I needed further help this.&lt;BR /&gt;&lt;BR /&gt;I have a tick-by-tick data looking like this:&lt;BR /&gt;&lt;BR /&gt;data work.item_1;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input date: $8. code: $6. datetime: 20;&lt;BR /&gt;datalines;&lt;BR /&gt;20180101 AAAAAA 01JAN2018 09:00:00.000&lt;BR /&gt;20180101 AAAAAA 01JAN2018 09:03:25.127&lt;BR /&gt;20180101 AAAAAA 01JAN2018 09:12:30.250&lt;BR /&gt;20180101 AAAAAA 01JAN2018 09:12:37.776&lt;BR /&gt;20180101 AAAAAA 01JAN2018 09:14:10.233&lt;BR /&gt;;;;;&lt;BR /&gt;&lt;BR /&gt;This is one example of several datasets I have.&lt;BR /&gt;above is the first 5 obs, but the actual data are much longer and of many dates.&lt;BR /&gt;And the last column (datetime) is later formatted with datetime30.3 format.&lt;BR /&gt;&lt;BR /&gt;I want to turn this dataset into a 5 min interval dataset&lt;BR /&gt;SO THAT the first observation would be 2&lt;BR /&gt;and the second observation be 0&lt;BR /&gt;and the third observation be 3.&lt;BR /&gt;&lt;BR /&gt;I was able to make 5min interval data but I couldnt make the sas to count the second to be 0 since there is no data b/w 09:05:00 and 09:10:00.&lt;BR /&gt;It would help me a lot if I can get some help on this.</description>
      <pubDate>Wed, 10 Oct 2018 06:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/502991#M134338</guid>
      <dc:creator>LzEr23</dc:creator>
      <dc:date>2018-10-10T06:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: making tick-by-tick data into time interval data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503009#M134345</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for trying to supply the input data as a data step, however it needed amending to create a data set that holds the data being read, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.item_1;
   infile datalines truncover;
   input date: yymmdd8. code: $6. datetime datetime22.3;

   format date     yymmddn8.
          datetime datetime22.3
   ;

   datalines;
20180101 AAAAAA 01JAN2018 09:00:00.000
20180101 AAAAAA 01JAN2018 09:03:25.127
20180101 AAAAAA 01JAN2018 09:12:30.250
20180101 AAAAAA 01JAN2018 09:12:37.776
20180101 AAAAAA 01JAN2018 09:14:10.233
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had trouble understanding the requirements, so would you please also create a data step showing the output data set you require, based on the input, thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 09:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503009#M134345</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-10-10T09:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: making tick-by-tick data into time interval data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503020#M134349</link>
      <description>I'm sorry. I'm quite new with sas, and I don't think I properly understood what you mean by 'data step showing the output data set I require.'&lt;BR /&gt;The data step you amended above is correct, and I don't see what exactly is it that you are asking?</description>
      <pubDate>Wed, 10 Oct 2018 10:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503020#M134349</guid>
      <dc:creator>LzEr23</dc:creator>
      <dc:date>2018-10-10T10:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: making tick-by-tick data into time interval data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503022#M134351</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have created a data step to show your input data. I am asking that you create another data step that shows the output data that you want to see.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The principle will be the same as you coded in your question, just use similar code with new lines of data so that another data set (table)&amp;nbsp;is created based on your data step (SAS code).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that's clearer, if not, just ask.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 10:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503022#M134351</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-10-10T10:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: making tick-by-tick data into time interval data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503026#M134354</link>
      <description>&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still not sure about what you're asking. But above would be something similar to what I want to get as an output set.&lt;/P&gt;&lt;P&gt;I hope this would be informative.&lt;/P&gt;&lt;P&gt;If I got it wrong, please tell me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; work&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;item_output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token statement"&gt;infile&lt;/SPAN&gt; datalines truncover&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; interval: $8. volume;&lt;BR /&gt;
&lt;SPAN class="token datalines"&gt;   ;
   &lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;01010900 2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;01010905 0&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;01010910 3&lt;BR /&gt;; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 10:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503026#M134354</guid>
      <dc:creator>LzEr23</dc:creator>
      <dc:date>2018-10-10T10:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: making tick-by-tick data into time interval data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503041#M134365</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you. I think I understand, you want to count how many observations fit in every five minute interval.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I coded the following which just works with the data provided, but I think it might&amp;nbsp;need amending to handle all cases:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(keep = boundary1 volume rename = boundary1 = interval);
   format boundary1 boundary2 datetime22.3;

   retain volume    0
          boundary1 '01JAN2018 09:00:00.000'dt
          boundary2 '01JAN2018 09:05:00.000'dt
   ;

   set item_1 end = last_obs;

   if boundary1 le datetime lt boundary2 then
      volume + 1;
   else
   do;
      do while(not (boundary1 le datetime lt boundary2));
         output;
         volume    = 0;
         boundary1 = boundary2;
         boundary2 = boundary2 + '00:05't;
      end;
      volume = 1;
   end;

   if last_obs then
      output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: Tweaked code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 12:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503041#M134365</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-10-10T12:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: making tick-by-tick data into time interval data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503071#M134378</link>
      <description>&lt;P&gt;Thank you so much!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed some bits to suit my data,&lt;/P&gt;&lt;P&gt;but this just works perfectly, and gave exactly what I hoped for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a really nice day.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 13:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/making-tick-by-tick-data-into-time-interval-data/m-p/503071#M134378</guid>
      <dc:creator>LzEr23</dc:creator>
      <dc:date>2018-10-10T13:16:25Z</dc:date>
    </item>
  </channel>
</rss>

