You shouldn't need to ask this question. Some
experiments would give you an answer.
First, -sample- leaves only the sample in memory.
My code just tags the sample on the assumption
that you know what you want to do with it. The
rest of the data are still there.
drop if !select
gets rid of them.
Second, I set the -seed- explicitly. Only if
you just set the -seed- yourself to the
same seed just before using -sample- would you expect
to get the same result. Perhaps not even then.
Nick
[email protected]
Ada C. Chen
Thanks!
Will it be the same by the following syntax?
sort hhid
by hhid:sample 1, count
2007/4/10, n j cox <[email protected]>:
> set seed 12345
> gen random = uniform()
> bysort hhid (random) : gen byte select = _n == 1
>
> Ada C. Chen
>
> Could anyone suggest me how to use STATA to randomly select one person
> within a household? (says, there may be one to many persons within the
> same household) I have a dataset of individuals and each has a
> household ID.
*
* 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/