I am trying to use "egen newvar = count()" to generate a set of variables
indicating frequency of old variables. The syntax is (as stated in the
egen nwear = count(exp)
I was wondering what this "(exp)" means (there is no example for this
particular type of egen).
For example, I have variable GENDER (1: men, 2: women), CITY(a, b,
c,d,e,f). I want to generate variables that show 1) number of men in each
city, 2) number of women in each city, and 3) total number of people in
each city. So I type:
by CITY: egen nm=count(GENDER==1)
by CITY: egen nw=count(GENDER==2)
by CITY: egen np=count(GENDER)
Stata generates all three variables with complains, but surprisingly, all
three new generated variables are exactly identical (all equal the total
number of people)! Can anyone please give me a hand? Thank you very much!