Three backslashes in outreg2 tex tables?
Asked Answered
L

3

6

I'm having trouble with the user-written outreg2 package used in Stata. When I build the output with the tex(frag) option, the resulting tables have three backslashes at the end of each line rather than just two, resulting in a "misplaced alignment character" error for each line. Any ideas on what I'm doing wrong or how to fix this?

(first regression specification)
outreg2 d.lntau_sh d.lntau_sf using Table_1.tex, nocons replace
(second regression second regression specification)
outreg2 d.lntau_ht d.lntau_th using Table_1.tex, tex(frag) se coefastr symb(***,**,*) rdec(3) bdec(3) r2 nocons append
Loutish answered 19/6, 2013 at 6:55 Comment(3)
outreg2 is a user-written program written for use in Stata. It is a good convention to explain that. That said, you don't show any full and precise examples of code, so even users of outreg2 are not given much to go on. I don't use it, so I stop here.Gannon
Thanks, I amended my post accordingly.Loutish
I will add that although this is a popular package, very few of its users seem to understand it well. In practice, emailing the author directly may be advisable. Also, for anyone attracted by the latex tag, the answer if there is one lies, I suspect, within the Stata program or its documentation.Gannon
S
5

This answer is specific to Windows. I encountered the same problem. It seems to be specific to the most recent version of outreg2 (outreg2 2.2.5 19mar2012). I fixed the problem as follows: open "C:\ado\plus\o\outreg2.ado" in Notepad; use CTRL+H to replace all instances of three backslashes into two backslashes (there should be three instances replaced); save (CTRL+S).

Skeleton answered 25/7, 2013 at 15:53 Comment(1)
Presumably you meant to refer to outreg2.ado, not outreg2.do. Also, Unix and Mac users would need to revise the Windows-specific details here.Gannon
A
2

I ran your code (for second regression) using Stata's auto data. I am not sure what error you are pointing to. I was able to generate the pdf file from latex output.

................ Stata code ................

sysuse auto 
regress mpg foreign weight
outreg2 using myfile2, tex(frag) se coefastr symb(***,**,*) rdec(3) bdec(3) r2 nocons append 

.......................... latex output ..................

\documentclass[]{article} This is added 
\begin{document}  This is added 
\begin{tabular}{lcc} \hline
 & (1) & (2) \\
VARIABLES & mpg & mpg \\ \hline
 &  &  \\
foreign & -1.650 & -1.650 \\
 & (1.076) & (1.076) \\
weight & -0.00659*** & -0.007*** \\
 & (0.000637) & (0.001) \\
Constant & 41.68*** &  \\
 & (2.166) &  \\
 &  &  \\
Observations & 74 & 74 \\
 R-squared & 0.663 & 0.663 \\ \hline
\multicolumn{3}{c}{ Standard errors in parentheses} \\
\multicolumn{3}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1} \\
\end{tabular}
\end{document} This is added 

........................ ......pdf output from latex output.....

enter image description here

Note: you can remove the append option if you don't want the second column to appear.

Amberlyamberoid answered 19/6, 2013 at 12:29 Comment(2)
Thanks for that, but I'm still confused - you haven't done anything different from my code, but your result is different at one crucial point: you get \\ after each line of the table, while I get \\\. Any ideas why this happens?Loutish
I have no idea. I am using Stata 11 and TeXnicCenter 2.0 Beta 1 for latex. Hope that may help. You can update you question with the output and flag the moderator to migrate your question to latex community if you are still having the same problem (but, I suspect this will be too localized for the latex community)Amberlyamberoid
T
0

I had a similar problem and solved it by reinstalling the packages this way:

ado uninstall outreg
ado uninstall outreg2

and then reinstalling outreg2 again:

 ssc install outreg2
Tuppeny answered 15/2, 2015 at 6:3 Comment(1)
Uninstalling outreg is completely irrelevant here. It's an entirely different package and does not share code.Gannon

© 2022 - 2024 — McMap. All rights reserved.