Hello Members,

I have data on individuals moving across regions and I have grouped each region into quantiles. What I am interested in is measuring how the average wage of individuals change as they move across regions into different quantiles. For example, suppose we have individuals who move from a region that is in quantile 1 to a region that is in quantile 2. What was the change in their average wage prior to the move (for two periods) and what was their average wage after they move (for two periods).

​​​​​​id region2_ wage
1 1 100
1 1 100
1 1 105
1 2 95
1 2 85
2 1 125
2 1 125
2 1 135
2 2 90
2 2 90
2 2 90
3 2 95
3 2 95
3 1 130
3 1 130

Let's say regions 1 and 2 are in the same quartile, how would I write code to find average wage one year before the move, average wage when moved and average wage after moved? Also, a person has to be in that region in both regions for at least two periods.

I hope this makes sense and any guidance would be much appreciated.

Sam