Dear Community.


I have variables for 'probability to become obese', 'probabilities of osteoarthritis' and 'probability of death' for each individual.
Based on each of these probabilities, I would like to generate variables such as obesity, osteoarthritis and death with binary values (0 or 1).
In other words, I'd like to randomly assign a value of 0 or 1 to the variables(obesity, osteoarthritis, death) depending on each probability.
I'm considering a command like this, "generate byte OA = uniform() <= prOA", but it doesn't seem accurate.
Please give me your correct idea.

Thanks in advance.


Best regards,
Yunsun

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(id sex age agegr sexagegr sm pa) float(probese prOA prDTH)
 1 0 41 4 14 0 0 .0482027 .0045425 .0015648
 2 0 41 4 14 0 0 .0482027 .0045425 .0015648
 3 0 41 4 14 0 0 .0482027 .0045425 .0015648
 4 0 41 4 14 1 1 .0449715 .0045352 .0015648
 5 0 41 4 14 1 0 .9094359 .0069649 .0015648
 6 0 41 4 14 1 0 .9094359 .0069649 .0015648
 7 0 41 4 14 1 1 .9123892 .0069751 .0015648
 8 0 41 4 14 1 0  .043434 .0045318 .0015648
 9 0 41 4 14 1 0  .043434 .0045318 .0015648
10 0 41 4 14 1 1 .0449715 .0045352 .0015648
11 0 41 4 14 0 0 .0482027 .0045425 .0015648
12 0 41 4 14 1 0 .9094359 .0069649 .0015648
13 0 41 4 14 1 0 .9094359 .0069649 .0015648
14 0 41 4 14 1 0  .043434 .0045318 .0015648
15 0 41 4 14 1 0  .043434 .0045318 .0015648
16 0 41 4 14 1 1 .0449715 .0045352 .0015648
17 0 41 4 14 1 1 .9123892 .0069751 .0015648
18 0 41 4 14 1 0  .043434 .0045318 .0015648
19 0 41 4 14 0 0 .0482027 .0045425 .0015648
20 0 41 4 14 1 0  .043434 .0045318 .0015648
21 0 41 4 14 1 0 .9094359 .0069649 .0015648
22 0 41 4 14 1 0 .9094359 .0069649 .0015648
23 0 41 4 14 1 1 .0449715 .0045352 .0015648
24 0 41 4 14 1 1 .0449715 .0045352 .0015648
25 0 41 4 14 1 0 .9094359 .0069649 .0015648
26 0 41 4 14 1 0  .043434 .0045318 .0015648
27 0 41 4 14 1 0  .043434 .0045318 .0015648
28 0 41 4 14 0 0 .9180345 .0069946 .0027712
end