HI!
I have a panel firm level dataset, and would like to inspect variable's standard deviation for the studied period. The issue is that during one year, some firms have missing and some have zeros which hard to justified (a separate issue..). In addition, during one year, most first have missing observations.Hence, I would like to do the following:
The command taking into account all three conditions, would be the most welcomed. The code I use is the following:
However, the variable created contains only missings.. What am I doing wrong?
Thank you in advance.
I have a panel firm level dataset, and would like to inspect variable's standard deviation for the studied period. The issue is that during one year, some firms have missing and some have zeros which hard to justified (a separate issue..). In addition, during one year, most first have missing observations.Hence, I would like to do the following:
- create stdv for variable employment, ignoring the year of 2011 (id=5, table below)
- create std. for variable employment, ignoring any missing, no matter the year (id=6, table below)
- create std. for variable employment, ignoring zeros values from the calculation, no matter the year (id=7, table)
Code:
year id employment 2006 5 458 2007 5 2 2008 5 1 2009 5 1 2010 5 1 2011 5 2012 5 1 2013 5 1 2014 5 1 year id employees 2006 6 0 2007 6 1 2008 6 0 2009 6 2 2010 6 2 2011 6 2012 6 2013 6 2014 6 year id employees 2006 7 0 2007 7 1 2008 7 0 2009 7 2 2010 7 2 2011 7 3 2012 7 4 2013 7 6 2014 7 5
bysort id year: egen sd_emp=sd(employees) if year!=2011 & employees!=0 & employees!=.
Thank you in advance.
Comment