Dear statalists:
I want to sample from a grouid without replacement and generate newids,but I can't find samilar examples for reference. The decription of my question is as following:
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
I don't know how to write codes for the sampling process,.I wonder if you can give me some suggestions.Many thanks!
I want to sample from a grouid without replacement and generate newids,but I can't find samilar examples for reference. The decription of my question is as following:
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex webuse nlswork egen groupid = group(race msp collgrad not_smsa c_city south ) ****we will have 69 groups ****My question is:I want to sample 3 groups from groupid without replacement and recode them into new groupid ****For an example, after first sampling, whose groupid are 1,2,3 are sampled,it will have gen newgroupid1 = (groupid==1|groupid==2|groupid==3) ****after second sampling,whoes groupid are 2,4,7 are sampled,it will have gen newgroupid2 = (groupid==2|groupid==3|groupid==4) ****I want to repeat this sampling 100 times
I don't know how to write codes for the sampling process,.I wonder if you can give me some suggestions.Many thanks!

Comment