Dear Statalist,
I have the following data that show employment history of individuals
Now I want to transpose the data in long shape like the follows:
Note that the corresponding firm of an individual will depends on how long they stay in that firm in that year. For example, in April 2002, id 1 moved from firm 10 to firm 20, so they stay with firm 20 for more time than that of firm 10 in 2002. Therefore, the corresponding firm in 2002 if id 1 is 20.
There could be some year where the person is not employed at all (like id 2 in 2001). In this case even if they only start working for firm 50 from September 2002, the corresponding firm for them in 2002 is firm 50.
I tried several ways to do the transpose of the data but it doesn't work. I would appreciate if you can help me with this issue.
Thank you!
I have the following data that show employment history of individuals
id | firm_id | frommonth | fromyear | tomonth | toyear |
1 | 10 | 2 | 2000 | 4 | 2002 |
1 | 20 | 4 | 2002 | 7 | 2004 |
1 | 30 | 7 | 2004 | 10 | 2007 |
2 | 40 | 6 | 1998 | 8 | 2000 |
2 | 50 | 9 | 2002 | 11 | 2003 |
2 | 20 | 11 | 2003 | 8 | 2006 |
Now I want to transpose the data in long shape like the follows:
id | year | firm_id |
1 | 2000 | 10 |
1 | 2001 | 10 |
1 | 2002 | 20 |
1 | 2003 | 20 |
1 | 2004 | 20 |
1 | 2005 | 30 |
1 | 2006 | 30 |
1 | 2007 | 30 |
2 | 1998 | 40 |
2 | 1999 | 40 |
2 | 2000 | 40 |
2 | 2001 | . |
2 | 2002 | 50 |
2 | 2003 | 50 |
2 | 2004 | 20 |
2 | 2005 | 20 |
2 | 2006 | 20 |
There could be some year where the person is not employed at all (like id 2 in 2001). In this case even if they only start working for firm 50 from September 2002, the corresponding firm for them in 2002 is firm 50.
I tried several ways to do the transpose of the data but it doesn't work. I would appreciate if you can help me with this issue.
Thank you!
Comment