I would like to generate a variable that tags individuals who have moved (i.e., those who switched from working in one city to working in another city). I provide the very simple data example below.
Individual A worked for all time periods 1,2,3,4,5 in city 100.
Individual B worked in city 100 during time periods 1-2 but then moved to work in city 200 in time period 3 and kept working there during time period 4.
Individual C worked during time periods 1,2 in cities 200 and 300.
Individual D worked during time periods 2,3 in cities 100 and 400, didn't work in time period 4 and moved to work in city 300 in time period 5.
Individual E worked during time periods 1,2 in cities 100 and 500 and kept working only in city 500 during the remaining time periods
Code:
clear input str1 id byte period long city_code "A" 1 100 "A" 2 100 "A" 3 100 "A" 4 100 "A" 5 100 "B" 1 100 "B" 2 100 "B" 3 200 "B" 4 200 "C" 1 200 "C" 1 300 "C" 2 200 "C" 2 300 "D" 2 100 "D" 2 400 "D" 3 100 "D" 3 400 "D" 5 300 "E" 1 100 "E" 1 500 "E" 2 100 "E" 2 500 "E" 3 500 "E" 4 500 "E" 5 500 end
Thanks a million!
0 Response to Tagging individuals who migrated in panel data
Post a Comment