Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata to Latex

    Hi all,

    I'm trying to put tables of summary statistics - as a starter - into Latex, for the first time. I've tried using
    Code:
    eststo: quietly sum  var1 var2 var3
    Code:
    esttab using "/Users/Desktop/Data/example1.tex", label booktabs title(Summary Statistics\label {
    > tab1})
    in Stata,

    and then putting
    \input{example1.tex} in the .tex file that I've been using to write my paper so far. When I typeset it, I get the error "Undefined control sequence".

    What am I doing wrong?

    Thanks in advance

  • #2
    I'm not sure why you get this error message, but it seems to me that it's more related to LaTeX than to Stata. However, as one possible solution I can recommend using the -logout- command which converts result tables into various output formats.
    Code:
    ssc install logout
    
    logout, tex save(filename): quietly sum var1 var2 var3
    This code will save the descriptive table as *.tex file format in your current directory. Some additional formatting in your TeX editor might be needed afterwards though.

    Comment


    • #3
      It says that the file cannot be opened.

      Comment


      • #4
        Looking back to post #1, I believe the problem is that you did not include the option necessary to tell esttab to format your output for tex. Including the suffix .tex on your file name is not sufficient, from what I can tell from the help esttab output.

        I think your command should be something like
        Code:
        esttab using "/Users/Desktop/Data/example1.tex", tex label booktabs title(Summary Statistics\label {tab1})

        Comment


        • #5
          You can't put tex and book tabs in the same command; also I am not sure if the command creates a new tex file; I want to export the table in the tex file I'm already using. Is there a way of doing this?

          Comment


          • #6
            summarize does not create estimates, so eststo does not store them. You want to estpost summarize instead.

            Your code would look something like this:
            Code:
            estpost sum  var1 var2 var3
            esttab using "/Users/Desktop/Data/example1.tex", label booktabs title(Summary Statistics\label {tab1}) cells("mean sd min max") replace nomtitle nonum
            Note that "/Users/Desktop/Data/example1.tex" is an unusual path. I assume you have deleted your usename from it.

            The command does create a new file, and throws an error if it already exists. You can specify the replace option to overwrite the old file. Alternatively, you may also want the append option. I'm not sure about your usage case. Check the documentation.

            Comment

            Working...
            X