How to Randomly Assign to Groups of Different Sizes
问题 Say I have a dataset and I want to assign observations to different groups, the size of groups determined by the data. For example, suppose that this is the data: sysuse census, clear keep state region pop order state pop region decode region, gen(reg) replace reg="NCntrl" if reg=="N Cntrl" drop region *Create global with regions global region NE NCntrl South West *Count the number in each region bys reg (pop): gen reg_N=_N tab reg There are four reg groups, all of different sizes. Now, I