Dear all,

Background:

In this simplified dataset example, I am trying to perform causal inference using a Difference-in-Differences method.

This dataset contains panel data from Compustat merged with Thomson Reuters M&A dataset.


What I need to do:

Due to the nature of this data set, I have to match firms according to their size (ln(Assets) and then perform DID inference on the results.

In order to match the firms by Asset, I will use either Propensity Score Matching (psmatch2) or Nearest Neighbor Match (nnmatch).

After matching is done, I need to perform a DID estimation to see if there is a causal effect.


Slight Complication (OPTIONAL TO READ): The psmatch tutorials on the web are not very helpful to me because recorded date of actual merger is not the same as firm year.

As such, if I use the following code:

Code:
 
 gen Post1=Firm_Year[_n+1] if !missing(Merger)
Then my code is being generated on the same row as firm year, instead of same row as post-merger year (indicated by colors). Please refer to sheet 2 on the excel file to see what I mean.

For example: If I use the above code, then Firm 111 will write "Merger+1yr in Firm_Year 2001 (right beside Merger==1, 3F) instead of in the row for 2002 (4F). This is shown below.







My rough idea on how to do it:

1. Create Treatment variable (TrtMerge) and POST variables. Interact them. etc.

2. Perform Nearest Neighbor Matching or Propensity Score Matching on Asset and Firm_Year(should I match on firm year?)

3. Perform DID to see the causal effect of merger on Income
I am feeling stumped because I don't know how to deal with the problem mentioned above (getting POST to appear beside the actual merger year instead of the firm year).

This is the dataset on which I want to perform -psmatch2- or -nnmatch- and then perform DID. I have attached the file as well (sheet 3).




I am hoping if someone can provide me the code to this whole process and explain to me what is going on in the code.

I have been struggling with this for a while now, as I realize this is a little complex. I think it is warranted that I am offer a gift to anyone who can help me. Person with the best answer will receive a $20 Amazon gift card, after 24 hours time period from the time of this post (granted I have the solution by then).

Any help would be greatly greatly appreciated.