Hi there,
How can I count the missing observations in panel data by ID and Year wise?
Thanks for your time!
How can I count the missing observations in panel data by ID and Year wise?
Thanks for your time!
egen wanted = total(missing( gdp)) , by(id year) sum wanted Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- wanted | 8134 .3840669 .4864037 0 1
Year | Total missing observations (all variables) |
2001 | 55 |
2002 | 65 |
2003 | 0 |
2004 | 74 |
Country ID | Total missing observations (all variables) |
1 | 0 |
2 | 7 |
3 | 9 |
4 | 12 |
ds id year, not extd_total ers bmgdp extd reer tradegdp mr mi bmr tservice sfranc bc . egen missing = rowmiss(`r(extd_total ers bmgdp extd reer tradegdp mr mi bmr tservice sfranc bc )') . tab id if missing no observations . tab year if missing no observations
. sysuse auto, clear (1978 Automobile Data) . ds make, not price rep78 trunk length displacement foreign mpg headroom weight turn gear_ratio . egen missing = rowmiss(`r(varlist)') . tab foreign if missing Car type | Freq. Percent Cum. ------------+----------------------------------- Domestic | 4 80.00 80.00 Foreign | 1 20.00 100.00 ------------+----------------------------------- Total | 5 100.00 . tab rep78 if missing no observations . tab rep78 if missing, missing Repair | Record 1978 | Freq. Percent Cum. ------------+----------------------------------- . | 5 100.00 100.00 ------------+----------------------------------- Total | 5 100.00
egen nonmissings = count(y + x1 + x2 + x3), by(id) xtreg y x1 x2 x3 if count>9
Comment