Thanks for the hint to create a simplified version of the dataset. This made me realise that my intention of not making the example too complicated has backfired on me.
There are 4 observations for every ID (every household): 1) industry in year1 for male, 2) industry in year2 for male, 3) industry in year1 for female, 4) industry in year2 for female
I assume that I would need to sort the observations differently...? Or does this problem require a completely different approach?
Thanks a lot for your patience, I am new to Stata and barely have any coding experience (as you might have noticed).
Any suggestion on how to solve this is much appreciated! Thanks
There are 4 observations for every ID (every household): 1) industry in year1 for male, 2) industry in year2 for male, 3) industry in year1 for female, 4) industry in year2 for female
Code:
clear input ID year industry sex 1 1 3 1 1 2 10 1 1 1 3 2 1 2 3 2 2 1 10 1 2 2 3 1 2 1 10 2 2 2 3 2 3 1 42 1 3 2 42 1 3 1 7 2 3 2 8 2 end bysort ID (year): gen var=industry[1]==3 & industry[2]==10 if sex==1 list, sepby(ID) +----------------------------------+ | ID year industry sex var | |----------------------------------| 1. | 1 1 3 2 . | 2. | 1 1 3 1 0 | 3. | 1 2 10 1 0 | 4. | 1 2 3 2 . | |----------------------------------| 5. | 2 1 10 2 . | 6. | 2 1 10 1 0 | 7. | 2 2 3 1 0 | 8. | 2 2 3 2 . | |----------------------------------| 9. | 3 1 42 1 0 | 10. | 3 1 7 2 . | 11. | 3 2 8 2 . | 12. | 3 2 42 1 0 | +----------------------------------+
Thanks a lot for your patience, I am new to Stata and barely have any coding experience (as you might have noticed).
Any suggestion on how to solve this is much appreciated! Thanks
Comment