Hello there, I have a data set as follows: date Eventdate sales company 20150101 20150131 700 A 20150121 20150131 500 A 20150131 20150131 400 A 20150204 20150131 300 A 20150205 20150131 800 A 20150101 20150131 2000 B 20150201 20150131 3000 B 20150302 20150510 4400 B 20150422 20150510 3200 B 20150515 20150510 1600 B 20150611 20150510 2200 B 20150621 20150510 4400 B I want to create two new variables: Pre and post, which are the last reported sales data before the eventdate and the first reported sales data after the eventdate, respectively. The new data should look like the following: date Eventdate sales company pre post 20150101 20150131 700 A 500 300 20150121 20150131 500 A 500 300 20150131 20150131 400 A 500 300 20150204 20150131 300 A 500 300 20150205 20150131 800 A 500 300 20150101 20150131 2000 B 3200 1600 20150201 20150131 3000 B 3200 1600 20150302 20150510 4400 B 3200 1600 20150422 20150510 3200 B 3200 1600 20150515 20150510 1600 B 3200 1600 20150611 20150510 2200 B 3200 1600 20150621 20150510 4400 B 3200 1600 Can anyone help me? Thanks a lot!
... View more