Happy New Year Statalist!
I have 6 blocks of 400 samples that I'd like to randomly assign to groups of 50. I thought I could do this with egen cut, but I got unanticipated results
.set obs 6
.gen block = _n
.expand(400)
.sort v1
.egen id = fill(1/400 1/400)
.gen random = uniform()
.sort block random
.egen group = cut(random), group(8)
.tab group block
| block
group | 1 2 3 4 5 6 | Total
------+--------------------------------------------------------+-------
0 | 47 51 54 46 48 54 | 300
1 | 51 61 49 46 46 47 | 300
2 | 61 41 42 48 56 52 | 300
3 | 53 33 46 60 54 54 | 300
4 | 48 57 52 52 37 54 | 300
5 | 46 57 53 52 51 41 | 300
6 | 43 52 51 49 55 50 | 300
7 | 51 48 53 47 53 48 | 300
------+--------------------------------------------------------+-------
Total | 400 400 400 400 400 400 | 2,400
What would have been a better way to do this?
John Wallace�|�Research Associate�| Test Method Development
AFFYMETRIX, INC. | 3380 Central Expressway | Santa Clara, CA 95051 | Tel:� 408-731-5574 | Fax:� 408-481-0435
*
* 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/