Statalist The Stata Listserver

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

st: Re: random sample

From   "Michael Blasnik" <>
To   <>
Subject   st: Re: random sample
Date   Thu, 26 Oct 2006 11:15:02 -0400

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" <>
To: <>
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?


*   For searches and help try:

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