*** I had posted this on Stack Exchange and was directed here:

I have been working with panel data set with survey data. I have a set of villages that have received the treatment and a set that have not (classified treat = 0 or 1). I also have schooling dummies Primary school (prim), middle and high school (midhigh), boys primary (bprim), boys midhigh, girls primary (gprim) etc. Now I want to create a count table for which I wanted to create count variables by treated and not-treated using STATA. The following code seems to work but I am not entirely sure this is the correct way:

Code:
local school prim midhigh bprim bmidhigh gprim gmidhigh
foreach x in `school' {
egen `x'_treat = sum(`x') if treat == 1
egen `x'_nontreat = sum(`x') if treat ==0
}
Then, I was hoping to use the output to create the following count table using esttab (which is not an issue but for illustrative purposes)


Treated vs Non-Treated
prims # of primary schools
midhigh # of middle and high schools
bprim # of boys primary schools
bmidhigh # boys of middle and high schools
gprim # of girls primary schools
gmidhigh # of girls middle and high schools


Thank you in advance,

Nair