Hi there,
I am desperately looking for way to solve this problem!
I have a large dataset downloaded from CRSP containing shareprices and dates in order to run an Event study.
I had download the data for a long time Periode and want to drop all data outside of the estimation window.
Here Comes the Problem: Since some companies have more than one Event, I cannot just combine Company Name and date of the Event.
the set looks as follows:
Date Company Eventdate
12.3.2000 XXX 0
13.3.2000 XXX 0
14.3.2000 XXX 1
15.3.2000 XXX 0
16.3.2000 XXX 0
17.3.2000 XXX 0
12.3.2000 VVV 0
13.3.2000 VVV 0
14.3.2000 VVV 0
15.3.2000 VVV 0
16.3.2000 VVV 0
17.3.2000 VVV 1
18.3.2000 VVV 0
....
(about 3Mio obs, and many cases, where one Company has several eventdates)
Now I Need to create a dummy variable to show whether an observation is in the estimation window.
My idea was to generate a variable (estimation_window) by an if-syntax, checking whether this observation is in a certain range around the eventdate.
gen estimation_window=1 if Eventdate=1 in _n+100/_n-100 ...such that the range is always 200 observations around the current observation.
But this command is not working: invalid observation number
Is there an other way to make the range dependent on the observation, I am currently in?
I would be very grateful to get any advise!
Thanks alot!!
Raphael Gallen,
Switzerland
I am desperately looking for way to solve this problem!
I have a large dataset downloaded from CRSP containing shareprices and dates in order to run an Event study.
I had download the data for a long time Periode and want to drop all data outside of the estimation window.
Here Comes the Problem: Since some companies have more than one Event, I cannot just combine Company Name and date of the Event.
the set looks as follows:
Date Company Eventdate
12.3.2000 XXX 0
13.3.2000 XXX 0
14.3.2000 XXX 1
15.3.2000 XXX 0
16.3.2000 XXX 0
17.3.2000 XXX 0
12.3.2000 VVV 0
13.3.2000 VVV 0
14.3.2000 VVV 0
15.3.2000 VVV 0
16.3.2000 VVV 0
17.3.2000 VVV 1
18.3.2000 VVV 0
....
(about 3Mio obs, and many cases, where one Company has several eventdates)
Now I Need to create a dummy variable to show whether an observation is in the estimation window.
My idea was to generate a variable (estimation_window) by an if-syntax, checking whether this observation is in a certain range around the eventdate.
gen estimation_window=1 if Eventdate=1 in _n+100/_n-100 ...such that the range is always 200 observations around the current observation.
But this command is not working: invalid observation number
Is there an other way to make the range dependent on the observation, I am currently in?
I would be very grateful to get any advise!

Thanks alot!!
Raphael Gallen,
Switzerland
Comment