[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: Generating a new variable
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
egen pfemale = mean(sex == "F") , by(Tract)
sex == "F"
evaluates as 0 or 1.
If some of your sex values are "Male"
or "Female", you would need to modify
If your sex variable is numeric, you
would need to modify this approach.
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: