Hello. I'd like to make a value-weighted portfolio using bootstrapping with the dataset I've attached. Currently my do-file doesn't seem to weight the returns properly. I'd like for it to pick 5 returns (bsample) per yearmonth (strata), and based off of these 5 returns' corresponding mktcap, I'd like for it to make value-weighted return. As a very simple example I've provided a picture of how it would look in Excel. The area marked in yellow (summed value-weighted return) is what I'd like as the output.

bootstrap.dta
Bootstrap1 (2) - siste yabin.do
bootstrap.dta
Bootstrap1 (2) - siste yabin.do
