local n = 100 // reps times
mat R = J(`n',4,.)
drop if x==.
forvalues i=1/`n'{
forvalues j=1/4{
preserve
sample `j', count
qui sum
mat R[`i',`j']=r(sum)
restore
}
}
clear
inp x
1
2
2
3
.
end
drop if x==.
mkmat x,mat(a)
loc n=_N
clear
set ob `=2^`n''
forv i=1/`n'{
g u`i'=mod(int((_n-1)/2^(`n'-`i')),2)
g v`i'=a[`i',1]*u`i'
}
egen s=rowtotal(v*)
egen n=rowtotal(u*)
replace s=(s>=4)
collapse (sum)s,by(n)