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

st: systematic sampling


From   "Clint Thompson" <[email protected]>
To   <[email protected]>
Subject   st: systematic sampling
Date   Thu, 09 Sep 2004 11:01:34 -0600

Hello All ---
I am using Stata Intercooled, v.8.2.
Suppose I want to take a systematic sample, that is, I want to sort
then keep every 5th observation, of a fictitious dataset.  Aside from
going into the data editor and manually deleting observations one-by-one
(or using a series of drop/keep commands), is there a more elegant way
to do this??  My initial  idea was to generate a new variable using the
_n  system variable then keeping only those observations divisible by,
say, five.  Example:

sort varname
gen obsno = _n
keep if (obsno/5)
  
The above does not return any errors, but it does not drop any
observations either.  I concede that this is contrived and rarely used
in practice, nevertheless, I am interested in knowing if this can be
done w/ a few commands.  

Many Thanks, 
Clint Thompson
 
*
*   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