Then sort the dataset to prepare for another merge.īack in your original event dates dataset - not the 'eventcount' one! You need to create a matching set variable to identify the different event dates within each company. You need to create a variable that indicates which 'set' of observations within the company each observation belongs to. This is where your dataset can get VERY BIG, as we are duplicating the observations to however many counts of event we have per company. The 'eventcount' variable has been merged on to each stock observation, and tells Stata how many copies of that observation are needed. Now use Stata's 'expand' command to create the duplicate observations. The next step is to merge the new 'eventcount' dataset with your dataset of stock data. Save this as a new dataset - don't overwrite your dataset of event dates! Each company observation is associated with the count of event dates for that company. Use the dataset of event dates and generate a variable that counts the number of event dates per company.Ĭut the dataset down to just one observation for each company. Now, we need to find out how many event dates there are for each company. To check how much memory you have allocated, the command is query, and to check how big your file is, the command is describe. We will be creating some variables and possibly duplicating cases, so the dataset can get VERY BIG. Make sure that you have enough space in your driveįirst, set memory to a large enough size so that you can do the rest of the operations below. Once you finish the download, save theĭata on your computer or where you have write permission, like thesis folder in your H drive. See a counter on the bottom of Stata window which shows how much percent of the file has been downloaded.
#Sort stata download
The computer you are using Stata needs to be connected to the internet for this download to work. The stock return data for 2007 were obtained from CRSP daily stock (the sample dataset is only available The events, in this example, are merger announcement dates for 2007 obtained from That contain event information, and the other called stockdata. There are two data sets: one called eventdates, Using example dataĪlternatively, you may try the commands in our event studies example using our sample data set. If you already know that you have only one event per company, you may skip the instruction below, merge the eventdate andĪnd go to the Event Study with Stata page. Many events per company you have on your dataset, we recommend that you go through this exercise to check the number of events per company.
![sort stata sort stata](https://s2.studylib.net/store/data/018098855_1-879e89ef46f3f84d08385d063757ae3f-768x994.png)
#Sort stata full
You need a full set of stock observations to examine each event.
![sort stata sort stata](https://i.stack.imgur.com/FM6r9.jpg)
Observations for each event date/company combination.
![sort stata sort stata](http://1.bp.blogspot.com/-3rqiMsOHkVc/VcnbYzIxz9I/AAAAAAAAD_s/64c1xMeU8K4/s1600/2015-08-11_15h35_14.png)
In multiple observations per company, it is necessary to create a duplicate set of Wish to examine more than one event date for each company. If a set of observations for each company can be matched to a single event date, the study will be much simpler. In the stock data, we have matching company id (company_id), stock return date (date), stock return (ret), and market return value (market_return). In the eventdates data, we have company id (company_id) and the date of event (event_date) as variables. In this example, we start with two data sets, one called eventdates and the other called stockdata. Usually people have two files, one for stock returns, and the other for your event of interest. You may have downloaded datasets for an event study, or created ones by entering data into excel sheets. Data Preparation for Event Studies using Stata Preparing your own data