First, please don't send mailjunk like .vcf
to the list. This request is prominent in
the FAQ and often repeated.
If your sex variable is a string you need
something like
egen pfemale = mean(sex == "F") , by(Tract)
as
sex == "F"
evaluates as 0 or 1.
If some of your sex values are "Male"
or "Female", you would need to modify
this approach.
If your sex variable is numeric, you
would need to modify this approach.
Nick
[email protected]
Fernando Augusto Proietti
> I have a large data set, with 15,000 observations, nested within 500
> census tract. Something like that:
>
> Census Tract Age Sex
> 1 23 Male
> 1 65 Female
> 1 68 M
> 2 35 F
> 2 48 F
> 2 56 M
>
> I want to generate two new variables, mean age and female proportion
> for each census tract. I was able to use egen and created the new
> variable mean age. However, I could not figure out how to
> create the new
>
> female proportion variable.
*
* 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/