Hi Statalist community,
I have employment data and I am trying to calculate gaps between employment. I define gaps between employment as episodes where a person is employed, then experiences a period of unemployment, and subsequently a period of employment.
The sample dataset is a balance panel dataset. In the sample dataset, the variables worker_id identifies a unique individual and quarter_id identifies the wage quarter. The variable participated is a dummy variable with 1 representing employment and 0 otherwise. The variable gap_between_employment is a dummy variable indicating if the quarter is part of a gap between employment. The variable number_of_gaps counts the number of gaps between employment. The variable longest_gap counts the longest length between employment.
Now, I'm stuck. I don't know how to create the variables gap_between_employment, number_of_gaps, and longest_gap. Any help would be appreciated. Thank you so much.
I have employment data and I am trying to calculate gaps between employment. I define gaps between employment as episodes where a person is employed, then experiences a period of unemployment, and subsequently a period of employment.
The sample dataset is a balance panel dataset. In the sample dataset, the variables worker_id identifies a unique individual and quarter_id identifies the wage quarter. The variable participated is a dummy variable with 1 representing employment and 0 otherwise. The variable gap_between_employment is a dummy variable indicating if the quarter is part of a gap between employment. The variable number_of_gaps counts the number of gaps between employment. The variable longest_gap counts the longest length between employment.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(worker_id quarter_id participated gap_between_employment number_of_gaps longest_gap) 1 1 1 0 0 0 1 2 1 0 0 0 1 3 1 0 0 0 1 4 1 0 0 0 1 5 1 0 0 0 1 6 1 0 0 0 1 7 1 0 0 0 1 8 1 0 0 0 1 9 1 0 0 0 1 10 1 0 0 0 1 11 1 0 0 0 1 12 1 0 0 0 2 1 1 0 0 0 2 2 1 0 0 0 2 3 1 0 0 0 2 4 0 0 0 0 2 5 0 0 0 0 2 6 0 0 0 0 2 7 0 0 0 0 2 8 0 0 0 0 2 9 0 0 0 0 2 10 0 0 0 0 2 11 0 0 0 0 2 12 0 0 0 0 3 1 1 0 1 3 3 2 1 0 1 3 3 3 0 1 1 3 3 4 0 1 1 3 3 5 0 1 1 3 3 6 1 0 1 3 3 7 1 0 1 3 3 8 1 0 1 3 3 9 1 0 1 3 3 10 1 0 1 3 3 11 1 0 1 3 3 12 1 0 1 3 4 1 1 0 0 4 4 2 1 0 0 4 4 3 0 1 1 4 4 4 0 1 1 4 4 5 1 0 0 4 4 6 1 0 0 4 4 7 1 0 0 4 4 8 0 1 2 4 4 9 0 1 2 4 4 10 0 1 2 4 4 11 0 1 2 4 4 12 1 0 0 4 5 1 1 0 0 3 5 2 0 1 1 3 5 3 0 1 1 3 5 4 1 0 0 3 5 5 0 1 2 3 5 6 0 1 2 3 5 7 0 1 2 3 5 8 1 0 0 3 5 9 0 0 0 3 5 10 0 0 0 3 5 11 0 0 0 3 5 12 0 0 0 3 end
- Individual 1 was employed for all 12 quarters so they didn't have any gaps between unemployment.
- Individual 2 was employed for quarter 1, 2, and 3 and then was unemployed for the rest of the quarters; individual 2 is right censored since he never found reemployment within the quarters of observation. Thus, he also doesn't have any gaps between unemployment.
- Individual 3 was employed in quarter 1 and 2, unemployed in quarter 3, 4, and 5 and then remployed from quarters 7-12. Individual 3 had 1 gap between unemployment with the longest length being 3 quarters.
- Individual 4 was employed in quarter 1 and 2, then unemployed between quarter 3 and 4, then employed between quarter 5, 6, and 7, then unemployed between quarter 8, 9, 10, and 11, and then finally employed in quarter 12. Individual 4 had 2 gaps between unemployment with the longest length being 4 quarters.
- Individual 5 was employed in quarter 1, then unemployed in quarter 2 and 3, employed in quarter 4, unemployed in quarter 5, 6, and 7, employed in quarter 8, and then unemployed in quarters 9-12. Individual 5 had 2 gaps between unemployment with the longest length being 3 quarters.
Code:
bysort worker_id: egen last_quarter =max(quarter_id) if participated==1
Comment