Hi all,
I am having a problem that might be just a mistake on understading how set seet works in the new Stata 14. I needed to select randomly three evaluations and create an average score per project so in my do file I set a seed, create a random number and selected the three evaluations with the largest random numbers per project. However when I run the do file, each time I get a different result. Why does that happen if each time the do file runs the seed is set at the same number?
The do file is the following:
clear all
set more off
set seed 988
gen random=runiform()
by iddelemprendimiento: egen r1=max(random)
gen ev1=1 if random==r1
by iddelemprendimiento: egen r2=max(random) if ev1==.
gen ev2=1 if random==r2
by iddelemprendimiento: egen r3=max(random) if (ev1==. & ev2==.)
gen ev3=1 if random==r3
gen evaluaciones=1 if ev1==1 | ev2==1 | ev3==1
collapse (mean) score if evaluaciones==1, by(iddelemprendimiento)
I am having a problem that might be just a mistake on understading how set seet works in the new Stata 14. I needed to select randomly three evaluations and create an average score per project so in my do file I set a seed, create a random number and selected the three evaluations with the largest random numbers per project. However when I run the do file, each time I get a different result. Why does that happen if each time the do file runs the seed is set at the same number?
The do file is the following:
clear all
set more off
set seed 988
gen random=runiform()
by iddelemprendimiento: egen r1=max(random)
gen ev1=1 if random==r1
by iddelemprendimiento: egen r2=max(random) if ev1==.
gen ev2=1 if random==r2
by iddelemprendimiento: egen r3=max(random) if (ev1==. & ev2==.)
gen ev3=1 if random==r3
gen evaluaciones=1 if ev1==1 | ev2==1 | ev3==1
collapse (mean) score if evaluaciones==1, by(iddelemprendimiento)
Comment