I have a dataset (N=300) from a study where participants were randomly allocated to 2 different teaching approaches. At the end of the study, they are meant to sit a test that they can either pass or fail; however, 10% did not attend the test. Of those who attend, the pass rate is 61% and I would like to, using this pass rate, estimate the N who would have passed amongst the ones who were a no show.

Having found some resources online - https://www.stata.com/support/faqs/s...andom-samples/ - I had a go at estimating pass rate for non-attenders in the dataset and would like to check the code appears correct to more advanced users:

g ok = noshow==1 //sets a 1 for those who did not attend

set seed 94523
g randu = runiform()

set ok randu
capture drop insample
bysort ok: g insample = (_N-_n)<30*.61 if ok==1 //creates a variable with 1 for those 30 who did not attend but would have passed based on pass rates in attenders

g pass_estimate = insample

I opted for using 61% across both intervention groups, although I guess a question is whether I should estimate the pas rate in each intervention arm and apply this separately to each arm?