Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Focusing on a particular age group in data set


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Focusing on a particular age group in data set
Date   Sun, 10 Apr 2011 18:22:24 +0100

In addition, note that this is an FAQ

FAQ     . . Creating variables recording whether any or all possess some char.
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        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

As -egen, max()- will take an expression for argument, the code can be
trimmed to something like

bysort householdid: egen hfem45 = max(sex==female & age <=45)
keep if hfem45

Nick

Fernando Rios Avila
==============

I think your best option is first to identify those households, and then use
that identification for the subsequent analysis.
To identify you could:
Gen fem45=0
Replace fem45=1 if sex==female & age <=45
Bysort householdid: egen hfem45=max(fem45)

That should identify in your household has any female 45 years old or
younger

On Sun, Apr 10, 2011 at 6:01 PM, Brendan Halpin <brendan.halpin@ul.ie> wrote:

> If you're working with a single wave, something like the following
> should work:
>
> . use qindresp
> . sort qhid qpno
> . gen femvalid = qage<=45 & qage>0 & qsex==2
> . by qhid: egen hhdvalid = max(femvalid)
> . keep if hhdvalid
>
> You should be able to generalise it for other structures (i.e., other
> waves, multiple waves).

Hassan Talal

I am trying to determine the socio-economic factors behind fertility using
British Household Panel Survey. I want to restrict the age group of female I
will be focusing on to maximum 45 years. As I am dealing with households, so
I will be analysing only those households which have <45 years old females.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index