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: [email protected] [mailto:owner-
> [email protected]] 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/