I generated a variable foo:

Code:
clear
set obs 100
gen foo=rnormal(5,2)
I then do the following:

Code:
gen foo2 = runiform()
replace foo if foo2 < 0.2
Is this correct? Will the mean and standard deviation of foo always be preserved?

Also, how can I randomly replace with . only a certain number of observations?