nulldata 100 scalar n = $nobs # generate n observations on x series x = uniform() # set a seed if you want to get same results each time you run this set seed 3213799 # Set the values of the parameters scalar slope = .5 # regression slope scalar sigma = 10 # measurement error in y scalar n = $nobs # start the loop, indicating the desired number of samples. loop 400 --progressive --quiet series u = normal(0,sigma) # generate sample of x and y series ystar=20+slope*x+u series y = (ystar>20) genr prop = mean(y) series y=y*ystar ols y const x tobit y const x print prop endloop