One way, would be to keep one observation from each household, randomly
sample from the remaining observations, and then merge back to the original
dataset.
For example:
sort hhid
preserve
tempfile tmp
bysort hh: keep if _n == 1
sample 10
sort hh
save `tmp'
restore
merge hh using `tmp'
keep if _m == 3
drop _m
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Ms. Marilyn Ibarra
> Sent: Friday, February 24, 2006 10:17 AM
> To: [email protected]
> Subject: st: random sample by hhid
>
> Anyone know how to draw a random sample by hhid? I want to
> draw a random sample at the household level, such that it
> keeps everyone in the household. I would like a one percent
> sample of households. So if I have 100 households but 500
> individuals, I would like for it to keep 1 household (that
> is all the members that belong to that 1 household).
>
> My data looks like this.
>
> Person hhid age
> Luis 1 30
> Nancy 1 35
> Joe 1 32
> Bren 2 15
> Jane 2 9
> Linda 3 11
> Tom 3 65
>
> Thanks,
> Marilyn.
> *
> * 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/