Announcement

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

  • Exporting two way summary stats from stata to latex

    Hi,

    I am trying to compute mean values of a variable by age group and year, see below of an example that is similar to what I want to do (instead of family income I want age group, instead of the names of candidates I want years, and instead of percentages I want mean). I am somewhat familiar with the expost and estabb combinations but I can't seem to find a way to get what I wanted from those programs. I read a bit about tabout but I am not familiar with that program's syntax and couldn't really get a tex file to work. Is there a simple way to do this?

    Best,
    Angela



    Click image for larger version

Name:	Screen Shot 2023-08-28 at 7.34.10 pm.png
Views:	1
Size:	63.9 KB
ID:	1725303








  • #2
    Assuming you are running version 18 (you are supposed to say in your post what version you are running if it is not the current version)
    Code:
    dtable i.family_income, by(candidate_voted_1991) export(my_file.tex)
    will do the job. Of course, replace the italicized material by the names of the corresponding variables and filename in your actual data set.

    Do read -help dtable- for further information about other options that can customize the appearance of the table.

    Added: I forgot that you are actually interested in means of a continuous variable, not percentages of votes for candidates. But you do not say what that continuous variable that you want means of is. Anyway, it seems what you want is something like

    Code:
    table (age_group) (year), statistic(mean some_continuous_variable) style(Table-1)
    collect export my_file.tex
    Do read -help table- for further information. Oh, and -table- became available in version 17.
    Last edited by Clyde Schechter; 28 Aug 2023, 19:21.

    Comment


    • #3
      Hi Clyde,

      Thanks for this! I am actually using version 17, will update Stata soon. I was aware that customizable tables existed but was not familiar with how to write the code for them. I will read more into it.

      Best,
      Angela



      Comment

      Working...
      X