#Typical call is %stmean1 c2-ck c1 c10 c11 c12 c13, where c2-ck contains #the subpopulations, c1 the sample sizes, #c10 and c11 a table of descriptive statistics, c12 the individual #stratum means and c13 the individual stratum standard errors macro stmean1 stratcol.1-stratcol.nlevel sizecol labcol descol mcol secol mcolumn stratcol.1-stratcol.nlevel sizecol labcol descol mcol secol subpops subsam mconstant npop nlevel stratmn stsemean i s1 s2 do i=1:nlevel let s1=sizecol(i) sample s1 stratcol.i subsam let s2=count(stratcol.i) let subpops(i)=s2 let mcol(i)=mean(subsam) let secol(i)=stan(subsam)*sqrt((s2-s1)/(s2*s1)) enddo let npop=sum(subpops) let stratmn=sum(subpops*mcol/npop) let stsemean=sqrt(sum((subpops*secol/npop)**2)) set labcol; format(a30). Stratified sample mean Estimated standard error end set descol stratmn stsemean end name mcol 'Stratum means' name secol 'Stratum standard errors' endmacro