From | Shige Song <[email protected]> |
To | [email protected] |
Subject | Re: st: question about egen |
Date | Thu, 17 Apr 2003 20:12:29 -0700 |
Shige -
If you just tabulate CITY, doesn't that tell you the total number of people living in each city (unless your dataset has multiple obs per person or something like that)?
I may not understand what you are trying to do, but based on what you said about wanting to create 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, can't you:
gen nm=city if gender==1
gen nw=city if gender==2
gen np=city
?
Sarah
--On Thursday, April 17, 2003 6:33 PM -0700 Shige Song <[email protected]> wrote:
Dear All, 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 Reference manual): 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: sort CITY 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! Best, Shige Song Department of Sociology, UCLA * * 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/Sarah A. Mustillo, Ph.D Center for Developmental Epidemiology Department of Psychiatry and Behavioral Sciences Duke University School of Medicine Box 3454 Durham NC 27710 919 687-4686 x234 * * 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/
* * 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/
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |