I am using Stata 17 with the commands below to post results to file but for some reason the file ends up empty
Code:
local DHSdir "D:/Data/1-CleanInput" local files : dir "`DHSdir'" files "*HR*.dta" tempname memhold tempfile results postfile `memhold' str10(survey) str40 (vlab) double(q1 q2 q3 q4 q5) int(q1_o q2_o q3_o q4_o q5_o) using `results' foreach f of local files { local f = substr("`f'", 1, strpos("`f'", ".")-1) di "`f'" local f_n = subinstr("`f'", "hr", "pr", .) di "`f_n'" if !inlist("`f'", "drhr21fl", "hrhh21fl", "pkhr52fl") { use "`DHSdir'/`f'", clear capture confirm variable hv005 if !_rc { gen wt=hv005*hv012 } capture confirm variable hv271 if !_rc { xtile windex10=hv271 [pweight=wt], n(10) } *drop hv106* capture confirm file "`DHSdir'/`f_n'.dta" if !_rc { qui merge 1:m hhid using "`DHSdir'/`f_n'", keepusing(hv106) assert(3) nogen local vlab: variable label hv106 di "`vlab'" *** Number of observations qui tab hv106 hv270, matcell(y) mata: st_matrix("yy", colsum(st_matrix("y"))) matrix list yy *** Percent qui tab hv106 hv270 [aw=hv005], matcell(x) mata: st_matrix("xx", (st_matrix("x") * 100) :/ colsum(st_matrix("x"))) * matrix list xx post `memhold' ("`f'") ("`vlab'") (xx[1,1]) (xx[1,2]) (xx[1,3]) (xx[1,4]) (xx[1,5]) (yy[1,1]) (yy[1,2]) (yy[1,3]) (yy[1,4]) (yy[1,5]) post `memhold' ("`f'") ("`vlab'") (xx[2,1]) (xx[2,2]) (xx[2,3]) (xx[2,4]) (xx[2,5]) (yy[1,1]) (yy[1,2]) (yy[1,3]) (yy[1,4]) (yy[1,5]) } } } *** Clean dataset use `results', clear brr
Thanks in advance!
0 Response to post doesn't post results successfully
Post a Comment