Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: data management


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: data management
Date   Sat, 19 Nov 2005 15:10:08 +0100

Kemal Aslan wrote:

I have the household data that contains the following variables:
hhid: household id.
hrelhd: relation to household head: if hhrelhd=3 that indicates the
individual is considered children.
age: age
female: the gender of individual
maxage: maximum age
bromaxage: maximum age for male children.

My aim is to calculate the number of older brothers.
----------------------------------------------------------------

I don't see what -maxage- and -bromaxage- are for; I guess that 19
is the maximum age to be classified as a child (although one had 16
as maxage; was that a typo?).

So, assuming that hhid, hrelhd, age, and female are the primary
variables, I did this:

clear
input str4 hhid hrelhd age female
10_7 1 43 0
10_7 2 38 1
10_7 3 19 0
10_7 3 16 1
10_7 3 13 1
10_7 3 11 0
end

// Make a separate category for offspring > 19 years.
replace hrelhd=4 if hrelhd==3 & age>19 & age<.

gen male=1-female
gsort hhid hrelhd -age
by hhid hrelhd: gen boysum = sum(male) if hrelhd==3
gen nolderbr=boysum-male
sort hhid hrelhd age
list

      +---------------------------------------------------------+
      | hhid   hrelhd   age   female   male   boysum   nolderbr |
      |---------------------------------------------------------|
   1. | 10_7        1    43        0      1        .          . |
   2. | 10_7        2    38        1      0        .          . |
   3. | 10_7        3    11        0      1        2          1 |
   4. | 10_7        3    13        1      0        1          1 |
   5. | 10_7        3    16        1      0        1          1 |
      |---------------------------------------------------------|
   6. | 10_7        3    19        0      1        1          0 |
      +---------------------------------------------------------+

Hope this helps
Svend

________________________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C,  Denmark
Phone, work:  +45 8942 6090
Phone, home:  +45 8693 7796
Fax:          +45 8613 1580
E-mail:       sj@soci.au.dk
_________________________________________________________

*
*   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