Announcement

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

  • Exporting output from command "table" to latex

    Dear users,

    I consider myself a relatively advanced user of Stata, but I have now faced a problem I cannot solve, which I think should be easy to solve. I am creating some descriptive statistics, where I want to show the mean of some variables and the sum of others, for different years. The code below produces exactly the table I want.

    Code:
    clear all
     webuse college, clear
     table year, c(mean gpa sum number)

    Unfortunately I have been unable to find any commands that export the output from the table command to latex. While there exists several commands similar to table (e.g. tabulate, tabstat), none have done exactly what I wanted do as many do not report the desired statistics "by year", while others do not allow me report the mean for one variable and the sum for others.


    So far, the only semi-solution I have arrived at is to manually collapse the data until the dataset itself looks like the data I want, i.e:
    Code:
    collapse  (mean) gpa (sum) number, by(year)
    browse
    followed by the texsave command (available online) that creates a latex table of the active dataset. This solution is not completely satisfactory as it require me to create new datasets, issues with the texsave command and that it seems to require heavier computations.

    Best regards,
    ​Eirik Eylands Brandsås

  • #2
    Howdy,
    just an idea:
    latabstat varlist , caption() clabel() statistics() columns(statistics) by(year)

    This is what I usually use. Hope it helps.
    Moritz

    Comment


    • #3
      I strongly recommend you to check the tabout (SSC) program by Ian Watson to produce shiny tables in Latex.

      Comment

      Working...
      X