I have a panel with different names over time and need to identify the new entrants and the dropped exits. Here is an example dataset.
I would like two outputs.
The first would have entrants (one per row) and look like:
The second would have exits (one per row) and look like:
My difficulty is that the names are not in the same variable position/name/label over time. I suppose you need to convert the original data into a name-year panel (one name and time per row). But I'm not sure how to do that simply. (The actual dataset has thousands of names.)
Thanks in advance for the help.
Code:
clear input timeid str2 name1 str2 name2 str2 name3 str2 name4 str2 name5 str2 name6 1 "a" "b" "c" "d" "e" 2 "c" "b" "d" "e" "f" 3 "a" "d" "e" "b" "c" 4 "c" "b" "a" "f" "g" "h" tsset timeid end
The first would have entrants (one per row) and look like:
Code:
clear input timeid str2 entrant 2 "f" 3 "a" 4 "g" 4 "h" end
Code:
clear input timeid str2 exit 2 "a" 3 "f" 4 "e" end
Thanks in advance for the help.
Comment