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

st: Sampling question


From   Marcello Pagano <pagano@hsph.harvard.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Sampling question
Date   Tue, 15 Oct 2002 20:25:16 -0400

Diana had trouble posting this.
To everyone:  Please only post plain ASCII text.
Statalist is set to block all other messages.  See FAQ.

Thanks,

m.p. 


This is a two part question.
  
 First: 
  
 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?
  
 My second question: If there is not a better way... how do I count the
number of records and save that number to programmatically to come up
with sample .316? Instead of typing .316
 in the program?
  
 Diana Sticker, MPH
 Center for Research on Occupational and Environmental Toxicology, L606
 Oregon Health & Science University
 Portland Oregon 97201
  
 Phone: (503) 494-2899
 Fax:      (503) 494-7397
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index