Hi,
I am trying to generate a variable (i.e. labor income_breastfeeding; employmentstatus_breastfeeding; etc...) for each of my observations in respect to the year that the mother was breastfeeding (year_breastfeeding). My data is panel data set with child-mother pairs and for example looks like this:
ID_child ID_mother year labor income year_breastfeeding laborincome_breastfeeding (desired var with desired values)
1 a 1989 34568 1990 36789
1 a 1990 36789 1990 36789
1 a 1991 37329 1990 36789
2 b 1983 50681 1984 54808
2 b 1984 54808 1984 54808
2 b 1985 55029 1984 54808
2 b 1886 56928 1984 54808
Therefore, the laborincome_breastfeeding for ID_child 1, ID_mother a, should be 36789 since 1990 is the year_breastfeeding and for ID_child 2, ID_mother b, laborincome_breastfeeding should be 54808.
I have tried the egen command; however, cannot seem to figure out how to do it correctly. I'm a bit new at state but perhaps a loop over observations would be best?
Any help would be greatly appreciated, thank you for your time and help!
Regards,
Surya
I am trying to generate a variable (i.e. labor income_breastfeeding; employmentstatus_breastfeeding; etc...) for each of my observations in respect to the year that the mother was breastfeeding (year_breastfeeding). My data is panel data set with child-mother pairs and for example looks like this:
ID_child ID_mother year labor income year_breastfeeding laborincome_breastfeeding (desired var with desired values)
1 a 1989 34568 1990 36789
1 a 1990 36789 1990 36789
1 a 1991 37329 1990 36789
2 b 1983 50681 1984 54808
2 b 1984 54808 1984 54808
2 b 1985 55029 1984 54808
2 b 1886 56928 1984 54808
Therefore, the laborincome_breastfeeding for ID_child 1, ID_mother a, should be 36789 since 1990 is the year_breastfeeding and for ID_child 2, ID_mother b, laborincome_breastfeeding should be 54808.
I have tried the egen command; however, cannot seem to figure out how to do it correctly. I'm a bit new at state but perhaps a loop over observations would be best?
Any help would be greatly appreciated, thank you for your time and help!
Regards,
Surya
Comment