Statalist The Stata Listserver


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

st: RE: Unexpected behaviour from -sample- with -if- and -by-


From   "Scott Merryman" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Unexpected behaviour from -sample- with -if- and -by-
Date   Mon, 30 Oct 2006 15:43:15 -0600

Keeping in mind the usual caveats about changing official Stata code, it
looks like line 83 of -sample- needs the `tokeep' term added to the sort, so
that it reads:

	sort `by' `tokeep' `u1' `u2' 

Scott


> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Peter Jepsen
> Sent: Monday, October 30, 2006 1:25 PM
> To: Statalist
> Subject: st: Unexpected behaviour from -sample- with -if- and -by-
> 
> Dear Stata-listers,
> 
> I need 10 random controls matched per case for an epidemiological study.
> Controls are matched to cases on birth month and gender. I am using the
> -sample- command, and my problem can be demonstrated with the following:
> 
> sysuse cancer, clear
> bysort drug: gen case=_n==1
> sample 10 if !case, count by(drug)		// Here, controls are
> matched to cases on drug, not birth month and gender.
> tab case drug
> 


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