I would like to randomly re-assign records based on criteria. For example in the table below, I would like to re-assign 30% of records where the ID is 4 to be an ID of 2, and 10% of the records where the ID is 3 to be an ID of 2. I have looked into the rand function using both bernoulli and uniform and can’t seem to get it right.
I believe using the rand(“uniform”) or rand(“bernoulli”) functions is what would work best, but I can’t seem to get the code dynamic enough to account for the specific percentages and also re-assign based on two different criteria.
Example Table
ekissau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2