Statalist The Stata Listserver

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

st: RE: RE: select a random obs from dataset

From   "Akihito Tokuhara" <>
Subject   st: RE: RE: select a random obs from dataset
Date   Fri, 19 May 2006 10:50:09 -0500

Dear Alex,

The commands worked well. Thank you very much.
I tested them on my dataset, but still not yet heard anything from my colleague.

By the way, what if, say, now I want to select 3 or 4 obs from each household,
with household_ID can be selected 2 or 3 times.

I mean, I tried to change the second command line, but the result is always only
one obs for each household.

Is there any keyword to look for in Help so that I can see the explanation in details
of that command line, or in relation to using -- uniform() -- because the Help in Stata
does not give me much info. Thank you very much in advance for any guide/help.

Best Regards,


From: "Alex Ogan" <>
To: <>
Subject: st: RE: select a random obs from dataset
Date: Wed, 17 May 2006 10:03:28 -0400

This will select one person randomly per household:

gen randomvar = uniform()
bysort householdid (randomvar): gen selectionflag = _n==1

-----Original Message-----
[] On Behalf Of Akihito
Sent: Wednesday, May 17, 2006 9:55 AM
Subject: st: select a random obs from dataset

Dear all,

My colleague wants to know how to select a random obs with some
from her dataset.
She wants to select one person randomly per household, but also with
condition that there is
no repetition of household (no household should appear twice in the
although the
person is different).

I don't know the method and I don't know if this can be done by Stata or

not. If there is a way, or some suggestions, I would appreciate very
Many thanks in advance.


Don't just search. Find. Check out the new MSN Search!

* For searches and help try:

This message is intended solely for the designated recipient(s). It may contain confidential or proprietary information and may be subject to confidentiality protections. If you are not a designated recipient, you may not review, copy, or distribute this message. If you receive this in error, please notify the sender by reply e-mail and delete this message.

Arrowstreet Capital, L.P. is an Equal Opportunity Employer.

* For searches and help try:
FREE pop-up blocking with the new MSN Toolbar get it now!

* For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index