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
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Nils Gudat
  • 13,222
  • 3
  • 39
  • 60
  • 2
    `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. – Nick Cox Jun 19 '13 at 07:55
  • Thanks, I amended my post accordingly. – Nils Gudat Jun 19 '13 at 09:10
  • 1
    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. – Nick Cox Jun 19 '13 at 11:06

3 Answers3

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).

Community
  • 1
  • 1
  • 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. – Nick Cox Jul 26 '13 at 08:04
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.

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
Metrics
  • 15,172
  • 7
  • 54
  • 83
  • 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? – Nils Gudat Jun 19 '13 at 17:48
  • 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](http://tex.stackexchange.com/) if you are still having the same problem (but, I suspect this will be too localized for the latex community) – Metrics Jun 19 '13 at 21:50
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
Nick Cox
  • 35,529
  • 6
  • 31
  • 47
  • Uninstalling `outreg` is completely irrelevant here. It's an entirely different package and does not share code. – Nick Cox Feb 15 '15 at 09:50