Hi Statalisters! I have the following problem.
I have N individuals and I would like to assign to them n random numbers. Since n<N what I need to do (I guess) is to generate n random groups of random size. I did the following:
generate rannum = uniform()
egen randomnumber = cut(rannum), group(n)
and it would work but it creates groups of equal size that is not what I need.
I also tried this:
gen randomnumber = runiformint(1,n)
which also would work but does not assign all the numbers between 1 and n (let us say, almost all for some reason I don't get), and again is not what I need.
Just to be clear, suppose N=10 and n=4, I'd like to have something like:
individuals randomnumber
1 2
2 3
3 3
4 1
5 4
6 1
7 3
8 4
9 2
10 1
Where randomnumber is randomly assigned to individuals.
Thanks for any help!
0 Response to random numbers to groups of random size
Post a Comment