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

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


From   "Nick Cox" <[email protected]>
To   <[email protected]>
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 
[email protected] 

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/



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