Announcement

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

  • Enter text in the top-left corner using collect

    Hello,

    I've been learning how to make and export tables using the collect command, and I'm really enjoying it. However, I can't seem to figure out how to put text in the upper-left corner of the table. I'd like to use this as an additional header for my Table 1. Does anyone know how I might do this?

    Thanks!

  • #2
    Are you referring to a title? If so, there's an option for that. If not, please elaborate.

    Comment


    • #3
      I'm talking about adding text in this upper left-hand corner, highlighted red in this example. Click image for larger version

Name:	Screen Shot 2021-12-05 at 2.08.36 PM.png
Views:	1
Size:	67.5 KB
ID:	1639540

      Comment


      • #4
        Hi.
        I'm bumping this thread because I often export -collect- generated tables from Stata to MS Excel and then feed them into Pivot tables for further manipulation/customized display, and that requires all columns to be named properly. So I would also like to know if there's a way to control what appears in this cell Cato highlighted in order to automate the process.
        Thanks.

        Comment


        • #5
          One work-around could be to hide column titles and levels, then create the first row(s) using -collect get-, see the FAQ https://www.stata.com/support/faqs/reporting/collect-get-custom-tables/
          Code:
          webuse nhanes2l, clear
          
          collect clear
          qui collect get, tag(model["(1)"]) : reg highbp age 
          qui collect get, tag(model["(2)"]) : reg highbp age i.sex
          
          collect style header model, level(hide) title(hide)
           
          collect get first_row = "B", tags(model["(1)"]) 
          collect get first_row = "C", tags(model["(2)"]) 
          collect label levels result first_row "A"
          
          collect layout (result[first_row] colname#result[_r_b]) (model)

          Comment


          • #6
            Thanks Bjarte, this is very neat.

            Comment

            Working...
            X