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.
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:
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
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
Best regards,
Eirik Eylands Brandsås
Comment