Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Support Needed on Matching Algorithm Code

From   Robert Carion <>
Subject   st: Support Needed on Matching Algorithm Code
Date   Mon, 14 Oct 2013 17:38:05 +0200

I need to run a matching algorithm on a very large dataset but I cannot figure out how to code it.

I’m using STATA 12.0 for Mac

For my Master in Finance thesis I need to run a matching algorithm in order to match firms that issued stock (SEO Firms) to firms that didn’t issue stock (Non-SEO Firms) based on three critierions (Market Capitalization, Market-to-Book and the prior 3 month stock return).

First, let me tell you how my data sets are structured. I have 2 files.

The first one contains all the equity issues I am interested in. For each observation (each equity issue) there is a company identifier (company ticker: ticker) and the date at which the equity issue took place (issue date: issuedate).

In the second file I have time series data, on a daily basis, for all the SEO firms and all the Non-SEO firms. Important to note is that the firms do not all have the same amount of data, firm 1 could have 4 years of data, firm 2 could have 7 years of data and so on. Also, the date at which the data starts is not the same for all the firms. The variables in this dataset are: company ticker (ticker), date (date), stock price (price), market capitalization(mrktcap), market-to-book(mrktbook), prior 3 month stock return(stockret) and a variable which is 1 if the company is an SEO  firm and 0 if it is a Non-SEO firm (SEO).


What I would need to do is the following:

1) For each month, sort the Non-SEO firms into deciles based on their Market Capitalization (mrktcap).

2) For each month, and within each decile, sort the Non-SEO firms into quintiles based on their Market-to-book (mrktbook).

3) For each equity issue, identify the month prior to that equity issue (equity issue date found in the first file)

4) For that month, choose among the 50 groups the one that matches the SEO-Firm’s Market capitalization and Market-to-book.

5) In the selected group, choose the Non-SEO firm which has the closest 3 month stock return (stockret) compared to the SEO firm and which has 3 years of stock price data after the equity issue date.

6) Rerun steps 3 to 5 for all the equity issues.

I realize I am essentially asking for the whole Stata code to run this process but even after a lot of googling developing the code needed is truly beyond what I am capable of doing. 

Thanks for all your help on this.


Robert Carion

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index