[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Counting combinations of two vars within groups defined by third var
Hello, I am sure there is a simple way to do the following but I haven't
been able to find it searching through the help files or the listserv
I have three variables - school (grouping variable), gender (binary), and
grad (binary). What I want to calculate is for each school, how many males
I have done the following:
sort sch gender grad
by sch: egen mg = count(lastsch) if gender==1 & grad==1
by sch: egen malegrads = max(mg)
However, this only works if there are one or more male grads in the school.
I can't figure out how to get zero values to populate in schools where the
if condition is not satisfied.
Thanks for your help!
Julie K. Rajaratnam
Department of Population and Family Health Sciences
Johns Hopkins Bloomberg School of Public Health
* For searches and help try: