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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: Re: random allocation [was:RE: programming question] |

Date |
Mon, 3 Nov 2003 14:56:00 -0000 |

Check out -by:- (various sections in the manual, plus a tutorial in Stata Journal 2(1):86-102 (2002)). set seed 31103 set obs 100 gen id = _n egen group = seq(), block(10) gen random = uniform() bysort group (random) : gen treatment = cond(_n <= 5, "A", "B") sort id l id group treatment Nick n.j.cox@durham.ac.uk Banya, Winston > Thank you very much for this Nick. I however have an > extension to the > question. What if I want to do the same exercise for say > 100 subjects but > ensuring that for every 10 subjects then number of > treatments are equal i.e > A=5 B=5. * * 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/

**Follow-Ups**:**st: RE: RE: RE: Re: random allocation [was:RE: programming question]***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: RE: Re: random allocation [was:RE: programming question]***From:*"Banya, Winston" <w.banya@imperial.ac.uk>

- Prev by Date:
**st: RE: Re: random allocation [was:RE: programming question]** - Next by Date:
**st: RE: RE: RE: Re: random allocation [was:RE: programming question]** - Previous by thread:
**st: RE: Re: random allocation [was:RE: programming question]** - Next by thread:
**st: RE: RE: RE: Re: random allocation [was:RE: programming question]** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |