Statalist


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

Re: st: counting with stata


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: counting with stata
Date   Mon, 19 May 2008 17:40:54 +0100 (BST)

--- Gauthier Tshiswaka-Kashalala <[email protected]> wrote:
> I am using a household survey data that has a household
> identification variable "HHid" and a variable "age" which gives the
> age of every member of the household. How do I use stata to create
> a variable defining the number of children in the household with age
> <= 5.

See the example below. The first part till end makes some toy data, the
-gen- command creates a variable that is 1 if a person is 5 years or
younger, and the command following creates the sum of this variable
within household id. 

*---------------- begin example ---------------
clear
input hhid age
1 4
1 6
1 8
2 3
2 1
end

gen byte young = age <= 5 if age < .
bys hhid : egen byte num_young = total(young)

list
*------------------ end example ----------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

-- Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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