Hi, I would like to know how can I draw a smaller sample (of say 20000) from an already existing large data set such as Demographic Health Survey using Monte Carlo Simulation. I want to use 1000 repitions to generate a beta coefficient value to check its consistency. I tried something like this. But it gave me one constant value of the 1000 beta. Would be glad if anyone can point out my mistake.

Code:
gen beta=.

quietly{
forvalues i=1(1)1000 {
   
    preserve
    
    //generating a random number and drawing first 20000 as samples from the data//
    set seed 135790
    gen random=runiform()
    sort random
    gen insample=_n<=20000

    //Panel regression//

    xtset id time
    xtreg y lag_y x1 x2 x3 x4 x5 //The variables are obtained from the already available data set//
    
    local coeff=_b[lag_y]
    restore 
    
    //Store the beta values//
    replace beta=`coeff' in `i'
    
    }
}

summ beta
Thanks in advance!