Dear Stata users
I am working with an unbalanced panel where dnr202115 is individual id, dnr2019129_cfar is office id, redovar is year, manfran is month from and mantill is month upto. I want to expand the yearly data into month-year data for each individual id using year manfran and mantill. For example, for invidual id 100000508 (first row), I would like to expand the panel to 2006m4-2006m10. here is my data:
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str9 dnr202115 long dnr2019129_cfar int redovar byte(manfran mantill)
"100000508" 219763 2006 4 10
"100000552" 2395641 2016 1 12
"100000552" 2395641 2017 1 12
"100000552" 2395641 2018 1 12
"100000711" 219698 2015 5 12
"100000711" 219698 2016 1 12
"100000711" 219698 2017 1 5
"100000711" 219698 2018 3 3
"100000726" 219682 2014 6 12
"100000726" 219682 2015 1 12
"100000726" 219682 2016 1 8
"100000933" 219532 2012 8 12
"100000933" 219532 2013 1 12
"100000933" 219532 2014 1 12
"100000933" 219533 2015 1 12
"100000933" 219533 2016 1 12
"100000933" 219533 2017 1 12
"100000933" 219533 2018 1 12
"100001438" 681356 2009 3 12
"100001438" 681356 2010 1 12
"100001438" 681356 2011 1 12
Would appreciate any help in this. I tried the following but I dont know how to reshape it as long format:
forvalues i=2005/2018 {
forvalues j=1/12 {
gen emp`i'm`j' = inrange(ym(`i',`j'),ym(redovar, manfran), ym(redovar,mantil))
}
}
Here emp`i'm`j'denotes the employment status dummy for a specific month.
Thanks,
Zariab Hossain
Uppsala University
I am working with an unbalanced panel where dnr202115 is individual id, dnr2019129_cfar is office id, redovar is year, manfran is month from and mantill is month upto. I want to expand the yearly data into month-year data for each individual id using year manfran and mantill. For example, for invidual id 100000508 (first row), I would like to expand the panel to 2006m4-2006m10. here is my data:
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str9 dnr202115 long dnr2019129_cfar int redovar byte(manfran mantill)
"100000508" 219763 2006 4 10
"100000552" 2395641 2016 1 12
"100000552" 2395641 2017 1 12
"100000552" 2395641 2018 1 12
"100000711" 219698 2015 5 12
"100000711" 219698 2016 1 12
"100000711" 219698 2017 1 5
"100000711" 219698 2018 3 3
"100000726" 219682 2014 6 12
"100000726" 219682 2015 1 12
"100000726" 219682 2016 1 8
"100000933" 219532 2012 8 12
"100000933" 219532 2013 1 12
"100000933" 219532 2014 1 12
"100000933" 219533 2015 1 12
"100000933" 219533 2016 1 12
"100000933" 219533 2017 1 12
"100000933" 219533 2018 1 12
"100001438" 681356 2009 3 12
"100001438" 681356 2010 1 12
"100001438" 681356 2011 1 12
Would appreciate any help in this. I tried the following but I dont know how to reshape it as long format:
forvalues i=2005/2018 {
forvalues j=1/12 {
gen emp`i'm`j' = inrange(ym(`i',`j'),ym(redovar, manfran), ym(redovar,mantil))
}
}
Here emp`i'm`j'denotes the employment status dummy for a specific month.
Thanks,
Zariab Hossain
Uppsala University
Comment