I would like to compare price observations inside a rolling time window of 10 minutes.
Let's say I have the following table with prices (left most column) on the products and the time at which they were sold:
data have;
input @1 PRICE 1. @6 PRODUCT $3. @12 DATE_TIME anydtdtm15.;
format date_time datetime17.;
datalines;
1 POW JAN-01-17 13:00
2 POW JAN-01-17 13:04
1 POW JAN-01-17 13:06
2 POW JAN-01-17 13:15
3 POW JAN-01-17 13:20
5 POW JAN-01-17 13:29
1 GAS JAN-01-17 13:05
2 GAS JAN-01-17 13:10
1 GAS JAN-01-17 13:39
;;;;
run;
What I need is a piece of code that will allow me to compare the prices in a 10 minute window. For example: the POW observation at 13:00 has a price of 1 and this price observation should be compared with all other price observations until 15:10 which are the same product. If there's a match on the price in this time window the matched rows should be spit out in a table.
This again has to be done for the observation at 13:04 and a price of 2, which then should be compared to observations until 13:14 and so on..
Can this be done?