Sampling in Stata

  EDS > Stata Sampling
printer friendly version Print
Page

Take a random percentage sample, in this example, 10%:
      sample 10
You can do this withing groups:
      by sex: sample 10

Take a random number sample, in this example, 100 records:
      sample 100, count
You can do this withing groups:
      by sex: sample 100, count
This version is also useful for picking the winner of a contest:
      sample 1, count

Take a sample of every nth record, in this example, keep every 10th record.:
      keep if mod(_n,10)==0