I need to randomly round a column of numbers up or down to the nearest 10. Is there a way to do this in Stata?
For example, in the dataset
, suppose I want to randomly round prices either up or down to the nearest 10. So then the price of the AMC Concord would be either 4,100 or 4,090 with equal probability.
Is there any way I could do this? I was thinking to round everything down and then generate a column of random 10s and zeroes and then adding them, but I'm not sure how to round down.
Thanks!
For example, in the dataset
Code:
sysuse auto, clear
Is there any way I could do this? I was thinking to round everything down and then generate a column of random 10s and zeroes and then adding them, but I'm not sure how to round down.
Thanks!
Comment