Dear all,
I have tried to use the Stata program -tabout- which is published by Ian Watson, I have run the suggesting codes of Ian Watson from the tutorial ( You can see this by downloading the attached file or search it via Google by typing "Publication quality tables in Stata:
a tutorial for the tabout program".
Then, copying and pasting the resutls to LaTex. Unfortunately, it does not work. How to fix it in order to get the 'standard' table. In the case, it is the Table #1 of the tutorial on page #13.
It is my first time using LaTex and -tabout-. Thank you all in advance!
I have tried to use the Stata program -tabout- which is published by Ian Watson, I have run the suggesting codes of Ian Watson from the tutorial ( You can see this by downloading the attached file or search it via Google by typing "Publication quality tables in Stata:
a tutorial for the tabout program".
Code:
/*tex
tex \usepackage{booktabs}
tex \usepackage{tabularx}
tex*/
texdoc init top, replace
/*tex
tex \begin{center}
tex \footnotesize
tex \newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
tex \begin{tabularx} {#} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
tex \toprule
tex*/
texdoc init bot, replace
/*tex
tex \bottomrule
tex \addlinespace[.75ex]
tex \end{tabularx}
tex \par
tex \scriptsize{\emph{Source: }#}
tex \normalsize
tex \end{center}
tex*/
sysuse cancer, clear
la var died "Patient died"
la def ny 0 "No" 1 "Yes", modify
la val died ny
recode studytime (min/10 = 1 "10 or less months") ///
(11/20 = 2 "11 to 20 months") ///
(21/30 = 3 "21 to 30 months") ///
(31/max = 4 "31 or more months") ///
, gen(stime)
la var stime "To died or exp. end"
tabout stime died using table1.tex, ///
cells(freq col cum) format(0 1) clab(No. Col_% Cum_%) ///
replace ///
style(tex) bt cl1(2-10) cl2(2-4 5-7 8-10) font(bold) ///
topf(top.tex) botf(bot.tex) topstr(14cm) botstr(cancer.dta)
sysuse nlsw88, clear
la var south "Location"
la def south 0 "Does not live in the South" ///
1 "Lives in the South"
la val south south
la var race "Race"
la def race 1 "White" 2 "Black" 3 "Other"
la val race race
la var collgrad "Education"
la def collgrad 0 "Not college graduate" 1 "College graduate"
la val collgrad collgrad
gen wt = 10 * runiform()
tabout south race collgrad [iw=wt] using table3.tex, ///
cells(freq row col) format(0c 1p 1p) layout(cb) h1(nil) h3(nil) npos(row) ///
replace ///
style(tex) bt font(bold) rotate(60) ///
topf(top.tex) botf(bot.tex) topstr(15cm) botstr(nlsw88.dta)
Code:
\begin{table}
& \multicolumn{9}{c}{\textbf{Patient died}} \\
\cmidrule(l{.75em}){2-10}
\textbf{To died or exp. end} & \multicolumn{3}{c}{\textbf{No}} & \multicolumn{3}{c}{\textbf{Yes}} & \multicolumn{3}{c}{\textbf{Total}} \\
\cmidrule(l{.75em}){2-4} \cmidrule(l{.75em}){5-7}\cmidrule(l{.75em}){8-10}
&No.&Col \%&Cum \%&No.&Col \%&Cum \%&No.&Col \%&Cum \% \\
\midrule
10 or less months&4&23.5&23.5&15&48.4&48.4&19&39.6&39.6 \\
11 to 20 months&6&35.3&58.8&8&25.8&74.2&14&29.2&68.8 \\
21 to 30 months&2&11.8&70.6&7&22.6&96.8&9&18.8&87.5 \\
31 or more months&5&29.4&100.0&1&3.2&100.0&6&12.5&100.0 \\
\textbf{Total}&17&100.0&&31&100.0&&48&100.0& \\
\end{table}

You either write in LaTeX or Word -- not both. If you want to use Word why not using tabout to produce a table that you can copy into Word and format it there?
Comment