Reweighting with bootstrapping and survey design

#1
Hello I am trying to do a DFL style reweighting with bootstrap weights and SEs. I have a 2 stage stratified sample over 5 rounds (repeated cross section).

The idea is to create counterfactual weights for the reference population and then find the difference in mean outcomes for the two groups. This difference can be divided into three parts Total difference (group 1 - group 2 , both using survey weights) Explained difference (group 2 using counterfactual weights- group 2 using survey weights) Unexplained difference (group 1 using survey weights- group 2 using counterfactual weights)

I have written the following program for the same

Code:
///to make sure there is no singleton strata
egen cluster_id= group(sector state region strat fsu)
egen stratum_id= group(sector state region strat)

foreach r in 1 2 3 4 5 {
preserve
qui keep if round==`r'
qui svyset cluster_id [pw=hhwt] , strata (startum_id)
qui unique cluster_id, by (startum_id) gen (dup)
qui by startum_id, sort: egen temp= total(dup)
count if temp==1
drop if temp==1  
drop temp dup
save "C:\Users\Round 2 Data\bs_round`r'", replace
restore
}


///final data we will use
use "C:\Users\Round 2 Data\bs_round1"
foreach r in 2 3 4 5 {
qui merge m:m round using "C:\Users\Round 2 Data\bs_round`r'"
drop _merge
sort round
tab round
}
save "C:\Users\Round 2 Data\bs_all"


///constructing bootstrap weights
egen pooled_cid= group (cluster_id round)
egen pooled_sid= group (stratum_id round)

svyset  pooled_cid [pw=hhwt], strata( pooled_sid)
bsweights bsw, reps(100) n(-1)  
svyset  pooled_cid [pw=hhwt], strata( pooled_sid) bsrweight(bsw*) vce(bootstrap)


///writing the program

#delimit ;

capture program drop mydfl;
program define mydfl, eclass properties (svyb);
version 13;
args wgtname xvars outcome;

    gen groupref=(group==1);
    egen countg1=sum(group==1);
    egen countg2=sum(group==2);
    logit groupref `xvars';
    predict phatref;
    gen `wgtname'2=(phatref/(1-phatref))*(countg2/countg1) if group==2;
    replace `wgtname'2=1 if group==1;
    gen `wgtname'1=((1-phatref)/phatref)*(countg1/countg2) if group==1;
    replace `wgtname'1=1 if group==2;
    drop phatref groupref countg*;
                forvalues i=1/2 {;
                                sum `wgtname'`i' if group==`i';
                                  replace `wgtname'`i' = `wgtname'`i' / r(mean) if group==`i';
                  };

    mean `outcome' if group==1 ;
    mat diff_1=e(b) ;
    mean `outcome' if group==2  ;
    mat diff_2=e(b) ;
    mean `outcome' if group==2 [pw=`wgtname'2] ;
    mat diff_3=e(b) ;

    mat dd_t = diff_1-diff_2 ;
    mat dd_e= diff_3-diff_2 ;
    mat dd_u= diff_1-diff_3 ;

    ereturn scalar dd_tot=e1(dd_t,1,1) ;
    ereturn scalar dd_exp=e1(dd_e,1,1) ;
    ereturn scalar dd_unex=e1(dd_u,1,1) ;

end;


///running the program
local xvars age i.state fhead yrs_ed marital rural
local outcome wage

svy bootstrap e(dd_tot) e(dd_exp) e(dd_unex): mydfl wtid "`xvars'" `outcome'
I want to find the standard error for the mean gap, mean explained gap and mean unexplained gap in outcome-in this case wage of the two groups.

I keep getting the following error (after the program creates wtid1 and wtid2)

Code:
  Bootstrap replications (100)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
************************************************xx    50
************************************************xx   100
insufficient observations to compute bootstrap standard errors
no results will be saved
What am I doing wrong? I really appreciate any help on this I can get.