[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: Unexpected behaviour from -sample- with -if- and -by-
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'
> -----Original Message-----
> From: firstname.lastname@example.org [mailto:owner-
> email@example.com] 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: