I have a panel of firms, and sometimes the id number of an establishment changes for administrative reasons. The subsequent id number is known, so the structure of the data is as follows, where id_next identifies the new value of a firm's id number in the subsequent period:
I'm after a way to generate a unique firm id number across changes in id number. In my example, firms 1-3 would be assigned the unique id 3, firm 4 the unique id 4. It feels like it shouldn't be too hard to do this iteratively, but I can't come up with a simple way to do it. Any suggestions are welcome. I am using Stata 14.
Code:
input id year id_next 1 1 . 1 2 2 2 3 . 2 4 3 3 5 . 3 6 . 4 1 . 4 2 .
Comment