Announcement

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

  • tabout - table title - for non-Latex users

    I've been using stata pretty regularly for a decade - as a big data epidemiologist and biostatistician. However, I'm now finding the need to build production quality tables automatically - for use in a clinical study report. I had been doing this kind of work "by hand" previously - which is a tedious job. In reading the excellent documentation for tabout, it seems possible to customize tables with titles; however, the documentation suggests one must use Latex. Yet, I have no experience with Latex. Truthfully, I don't even know what Latex is.

    Is it possible to add table titles when using tabout without using Latex?

  • #2
    I don't know why you have the impression that titles can only be added with Latex. Quoting from the -tabout- help file in regard to the -topf- and -botf- options:

    These are particularly useful for html and LaTeX users, and allow you to control the layout of the tables more precisely. All users will find them useful as a way of inserting additional information above and below the table, such as notes, populations, data sources (for the bottom of the table) and titles (for the top of the table). [Emphasis added.]
    Are you perhaps using an older version of -tabout-? The current version will run on Stata versions 9.2 onward. If your Stata is at least that recent and your -tabout- is not current, do update it.

    I should add that I'm a very infrequent user of -tabout- and I don't recall ever having specifically used this feature, (and, like you, I do not use Latex) but I believe it's available regardless.
    Last edited by Clyde Schechter; 28 Mar 2016, 20:07.

    Comment


    • #3
      If you are building the tables in a text file or excel (rather than Latex or HTML), you can add table titles through the -tabout- h1() or h2() header options. For more control over headers/footers, I like to use -filei- from ssc to insert table titles or notes. Here is an example using both of these to automate creating several tables in one excel file:


      Code:
      sysuse auto, clear
      
       **alternate method: add table titles manually with filei from SSC
       cap which filei
       if _rc ssc install filei
       
       
      **build tables in a loop using tabout
      
      loc i = 1
      cap rm `"table.xls"'
      foreach j in price mpg turn trunk headroom  {
       if `i' !=1 filei + "  `=char(10)'  "  `"table.xls"' //create some space between tables
       if `i' !=1 filei + "Table `i': for var `j' goes here"  `"table.xls"'
        tabout rep78 foreign   ///
         using `"table.xls"', append  sum ///
          c(mean `j' min `j' max `j') f(1c) h2(Here is another table `i' title for `j')
      if `i'==1 filei - "Document title goes here" `"table.xls"'
      loc i `++i'
         }
        
        
        **open this in excel**
       di `"{browse `"table.xls"': Open File}"'

      Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

      Comment


      • #4
        Thank you, Eric. I'm not that familiar with using loops; so I modified your code to add the table tile "manually" - using h2 (see the code below). As a follow-up question, is it possible to a note below the table?

        tabout screenstat_ using disposition_v1.xls, ///
        h2("Table 14.1.1.1 Subject Disposition (All Screened Subjects)") ///
        rep c(freq col)

        Comment


        • #5
          That's supposed to say...As a follow-up question, is it possible to add a note below the table?

          Comment


          • #6
            See the -topf()- and -botf()- options
            Stata/MP 14.1 (64-bit x86-64)
            Revision 19 May 2016
            Win 8.1

            Comment


            • #7
              Thanks Carole. I appreciate your response. That's how I ran into trouble before....I tried using the topf() to add a title; however, I could only find example code that required a latex file or something like that. (To be honest, I still don't know what Latex is).

              Is there a simple way to add a note or footnote at the bottom or below the table - without creating a separate document?

              topf and botf seem to both require linking other documents...which is beyond the scope of what I want to do.

              Comment


              • #8
                LaTeX is a markup language used for formatting documents. See: https://en.wikipedia.org/wiki/LaTeX.
                While tabout is used to facilitate table production in LaTeX, that isn't necessary.

                To your question about notes. Yes, botf() and topf() do use another document, but that document can be a simple text file with the "pound" symbol: #. The options topstr() and botstr() specify what to put in place of the #.
                1. Open notepad or the do file editor in stata.
                2. Type the single character: #
                3. Save the file as "note.txt" in the currrent working folder
                Now run your usual command with the additions shown:

                Code:
                tabout screenstat_ using disposition_v1.xls, ///
                h2("Table 14.1.1.1 Subject Disposition (All Screened Subjects)") ///
                rep c(freq col) botf(note.txt) botstr("HERE IS A NOTE")
                Stata/MP 14.1 (64-bit x86-64)
                Revision 19 May 2016
                Win 8.1

                Comment


                • #9
                  Carole you're a star. Thank you for your help. I really appreciate it. I was able to use the note.txt approach to create a title and a footnote with tabout.

                  Eric is a star too. I like his use of filei + and filei-.

                  Thank you both for your excellent help.

                  Comment

                  Working...
                  X