Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Sampling question


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: Sampling question
Date   Tue, 15 Oct 2002 20:58:01 -0500

----- Original Message ----- 
>  I would like to select a random sample of 100 records. Not a random
> sample of a # percentage of the data in memory. 
>  So I do the following commands on a database that has 31638 records.
>   
>  ----------------------------
>  . count
>  31638
>   
>  . sort CLAIMNBR
>   
>  . set seed 123456789
>   
>  . sample .316 
>  (31538 observations deleted)
>   
>  . count
>    100     /*I have 100 records because I know sample .316 would give me
> 100 records*/
>  --------------------------------
>   
>  My first question:  Is there a better way to do this?
>   

sample 100, count

or if you want to keep all the data you can use swor 

swor 100, gen(var1) keep

There is also a FAQ on sampling at:

http://www.stata.com/support/faqs/stat/sampling.html

Scott



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