1
votes

Say that I have this dataset:

webuse union, clear

I want to run a tabulation:

tab union smsa

I want to export it to a .tex file and have it look similar to the above tabulation. Is there a way to have code similar to the following display the labels (union worker and lives in SMSA) automatically instead of having to hard code them in?

eststo clear
eststo: estpost tab union smsa
esttab est1 using "${path}/example.tex", cell(b) unstack noobs ///
    replace nonum collabels(none) eqlabels(, lhs("union worker")) ///
    mtitles("lives in SMSA")
1
Corrected sysuse auto to webuse union.Nick Cox

1 Answers

2
votes

Can you clarify what you mean by "automatically"? I can't test this because those variables are not in the auto dataset when I load it, but you could call the variable label macro instead of the variable label explicitly:

eststo clear
eststo: estpost tab union smsa
esttab est1 using "${path}/example.tex", cell(b) unstack noobs ///
    replace nonum collabels(none) eqlabels(, lhs("`:variable label union'")) ///
    mtitles("`:variable label smsa'")

Try help extended_fcn for details.