Dear Stat users,
I have a problem in counting the observatios over groups and subgroups.
I have 20 groups in variable "state" and 3 subgroups each called
"district" within "state". Now I have a set of variables varX1 varX2 varX3
whose observations are to be counted by state(district)
Finally I should get some thing like :
for variable var1:
state district1 district2 district3
1 count of varX1 count of varX1 count of varX1
2
3
4
.
.
.
20
Similiarly for var2, var3 etc...
when I had only one group (state) I use to do it as follows:
local item "X1 X2 X3"
foreach X of local item {
egen No`X' = count(var`X'), by(state)
}
table state, c(m varX1 m varX2 m varX3) row
Now with an additional subgroup how can I do this?
Thanks in advance for your advice.
Rijo John.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/