I could not find a command that performs this simple task. I was hoping if
someone might have some advice. I have a variable named emp that looks
like this
emp Freq.
0 93,404
1 55,537
2 36,556
I want to replace emp=2 at random with 0 or 1 depending on the relative
number of 1s and 0s in the sample. My outcome should look like this
emp Freq.
0 116,329
1 69,168
Incidentally, if you happen to have Nick Cox's -egenmore- installed (type
-findit egenmore-) this will also work (the rndsub fnc as shown below
randomly assigns cases to 2 groups, with 62.71% going to group 1 and the
rest to group 2; this assignment only occurs where emp = 2).