I want to create 2 POST variables to observe the effects of a merger on a company.

Problem: The 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).

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).

Can someone please help me out with this?


Here is the image of the example dataset: https://i.imgur.com/AWpvYBs.png