Dear Statalists,
I would like to generate 67 random groups for 271 observations. I know the below code might work:
set obs 271
range no 1 271
gen r= uniform()
gen group=1
sort r
replace group=2 in 5/8
...
However, is there any better way that can be used to generate 67 random groups simultaneously?
Thanks in advance.
Best,
Cong
Related Posts with Random group generation
How do we test the hypothesis of coefficient stability across sub-groupHello everyone, I would like to know if there is a coefficient stability test between two models, o…
Extracting the column percentages from two tabDear Statalist, I need to calculate the difference between two percentages coming from two different…
Merging 4 variables into 1 on Stata?Hi there, I tried to use dataex but the following error emerged: "data width (406 chars) exceeds ma…
Fixing Scientific Notation in String VariableHi I have a dataset containing many observations. All variables are string variables (Type: str40 …
competing risk without covariatesI want to compare the risk of dying of a specific cancer versus "other causes" in a large sample. Co…
Subscribe to:
Post Comments (Atom)
0 Response to Random group generation
Post a Comment