Hi,
I want to assign random numbers to some amount of observations where the numbers have a constant sum. I want to set 120 observations and assign integers in range of (0,total) where the integers sum up to total. I started as shown below but I cannot fix the sum of r s to 196.
program define simulation, rclass
drop_all
set obs 120
gen r= runiformint(0,196)
end
I appreciate your help in advance.
I want to assign random numbers to some amount of observations where the numbers have a constant sum. I want to set 120 observations and assign integers in range of (0,total) where the integers sum up to total. I started as shown below but I cannot fix the sum of r s to 196.
program define simulation, rclass
drop_all
set obs 120
gen r= runiformint(0,196)
end
I appreciate your help in advance.
Comment