Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: multilevel


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: multilevel
Date   Tue, 18 Mar 2008 13:59:15 -0000

The number of children in school in each household may be put in a
variable by 

egen inschool = total(school), by(household_code) 

-inschool- will thus be constant within household. 

You can tag just one observation in each household by 

egen tag = tag(household_code) 

and then 

tab inschool if tag 

See also various FAQs, e.g. 

FAQ     . . Creating variables recording whether any or all possess some
char.
        2/03    How do I create a variable recording whether any
                members of a group (or all members of a group)
                possess some characteristic?
                http://www.stata.com/support/faqs/data/anyall.html

Nick
n.j.cox@durham.ac.uk 


Daniel Macneil

I am stumped on what i thought was an easy problem. I have children
(id_code) within 
families(household_code) who go to school (1) or not(0). How do I find
the mean values (or even 
table) at the household level for how many children are in school? I
know I can use xtsum to get 
the std dev within and between, but about just finding out: the number
of families with ALL 
children in school, SOME children in school and NO children in school,
e.g.

  +--------------------------------------------+
      | househ~e   id_code      sex   age   school |
      |--------------------------------------------|
   4. |        1         4   Female     6        0 |
   9. |        2         3   Female    12        0 |
  10. |        2         4     Male     8        1 |
  14. |        3         3   Female    12        0 |
  15. |        3         4     Male    10        1 |
      |--------------------------------------------|
  16. |        3         5     Male    14        1 |
  23. |        4         3   Female    14        0 |
  24. |        4         4   Female    12        1 |
  25. |        4         5   Female     6        0 |
  32. |        5         5   Female    13        . |
      |--------------------------------------------|

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index