Quantcast
Channel: The Stata Blog - Latest Comments
Viewing all articles
Browse latest Browse all 1125

Re: Export tables to Excel

$
0
0

Just as a follow up, I believe I found a suitable fix using the user-written command 'fre' , where you can specify all values to be tabulated. I thought I would post it here in case anyone ran into a similar issue. Here it is within a loop (by district_name). There may be a more elegant solution here, but this gives me accurate counts/labels for each district, even if there are not both males and females in the subsample.


fre gender if district_name=="`d'", includelabeled include(0 1)
putexcel A4 = "Sex" ///
B4 = "Female" ///
B5 = "Male"
putexcel C4 = matrix(r(valid)), hcenter nformat(number_d2)
putexcel D4 = formula(=C4/`r(N)') ///
D5 = formula(=C5/`r(N)'), nformat(percent_d2)


Viewing all articles
Browse latest Browse all 1125

Trending Articles