The Datasets here are for example only, my real datasets are for up to 1.5 million observations. I have 2 products 'A' and 'B' trading, trade_time and trade_price are recorded variables, so I have DATA product_A; INPUT A_datetime datetime16. A_price $; DATALINES; 22JUN11:00:00:04 1.7 22JUN11:00:00:08 1.9 22JUN11:00:00:10 2.3 22JUN11:00:05:12 2.9 22JUN11:00:05:36 3.5 22JUN11:00:32:45 3.2 22JUN11:00:39:01 3.1 22JUN11:00:39:03 2.7 22JUN11:01:10:12 2.6 22JUN11:07:22:10 2.1 26JUN11:12:42:17 3.4 26JUN11:12:42:18 3.6 26JUN11:12:42:21 3.9 ; RUN; DATA product_B; INPUT B_datetime datetime16. B_price $; DATALINES; 22JUN11:00:00:09 0.02 22JUN11:00:05:34 0.07 22JUN11:00:39:05 0.04 26JUN11:12:42:20 0.09 ; RUN; Each time 'B' trades, i want to know what 'A' traded at, but only if 'A' traded within the last 5 seconds looking backward. (i.e if B trades and there are no records in the last 5 seconds for A, then discard, even if 'A' trades one second afterwards, - looking backwards in time only) So I want to create a new dataset called 'same_trade_times'. which would have the following data,... DATA same_trade_times; INPUT B_datetime datetime16. B_price $ A_datetime $ A_price $ ; DATALINES; 22JUN11:00:00:09 0.02 22JUN11:00:00:08 1.9 22JUN11:00:39:05 0.04 22JUN11:00:39:03 2.7 26JUN11:00:42:20 0.09 26JUN11:12:42:18 3.6 ; RUN; any ideas on this one?
... View more