So I have a dataset with trading data that has been merged with block trades, which are essentially just very large trades all happening at once and executed by a big financial institution of some kind.
I am trying to see how the price of the security moves right after the block trade specifically in the minutes before and after a block trade.
The data has a variable called Date_Time which has the date and time and is formatted like this: 08FEB03: 03:20:00 (which would be February 8th 2003 at 3:20:00 AM). It also has a dummy variable for when a trade is classified as block trade, which says "Block" if its a block trade and is missing if its not a block trade.
What I would like to do is find every block trade and create a variable that has the time lapse after and before the block trade. For instance, if a block trade happened at 3:20 AM on February 8th 2010 then I want to look at the price at the trades executed right before (lets say at time 3:16 and time 3:19 if those are the trades right before) and also right after (such as at 3:21 and 3:23 if those are the trades right after). Right now I am only trying to look at 30 minute intervals. Therefore I would like my data to look like this
Date_Time|Block|Price|Time_From_Block_Trade
08FEB08:03:16:00 "." 113.01 -4
08FEB08:03:19:00 "." 113.02 -1
08FEB08:03:20:00 "Block" 113.02 0
08FEB08:03:21:00 "." 113.07 1
08FEB08:03:23:00 "." 113.09 3
I have everything except I don't know how to create the Time_From_Block_Trade variable at all. There are a bunch of block trades in the dataset and I would like to figure out how to create a variable that has the difference in the Date_Time between the block trade and the trades that occurred right before and right after the block trade.
I tried doing something with proc expand but I just can't seem to figure this out. Sorry if this is really easy but I am brand new at SAS.