Statalist The Stata Listserver


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

st: Re: random sample


From   "Marcella Sapun" <[email protected]>
To   <[email protected]>
Subject   st: Re: random sample
Date   Thu, 26 Oct 2006 11:31:13 -0400

Thank you Michael for your suggestion. It worked nicely too!
Marcella
 

>>> Michael Blasnik <[email protected]> 10/26/2006 11:15 AM
>>>
...
If you can read in the dataset, then I'd recommend using the -sample- 
command.  But if you can't, then you can :

use myfile if uniform()<.1

which will select about 10% of the observations.  If you want exactly
10%, 
then use something bigger than 0.10 and then use -sample- :

use myfile if uniform()<.15
sample 100000

You probably want to set the random number seed before any of these 
approaches if you want replicable results.

Michael Blasnik


----- Original Message ----- 
From: "Marcella Sapun" <[email protected]>
To: <[email protected]>
Sent: Thursday, October 26, 2006 10:57 AM
Subject: st: random sample


> Dear statalisters:
>
> I want to read randomly 10% of a data set that contains about 1
million
> records and 100 variables. How do I do that in stata?
>
> Thanks,
>
> Marcella

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



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