Hi,
I would like to produce a stratified sample of 250 clusters based on a variable that store the information of how much clusters would come to the main sample from each strata.
One solution is to keep each strata and draw the sample using the sample formula. Such as
and so on for other 32 unique ids
However, doing this process over and over again is time consuming. Is there a way to code this sampling based on a count variable for each strata.
I am looking for something like this
Thank you.
I would like to produce a stratified sample of 250 clusters based on a variable that store the information of how much clusters would come to the main sample from each strata.
One solution is to keep each strata and draw the sample using the sample formula. Such as
Code:
preserve keep if id == 1 & gender == "boys" sample 4,count tempfile sample1 save `sample1' restore keep if id == 1 & gender == "girls" sample 5,count tempfile sample2 save `sample2'
However, doing this process over and over again is time consuming. Is there a way to code this sampling based on a count variable for each strata.
I am looking for something like this
Code:
sample countvariable,count by(id gender)
Comment