Announcement

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

  • How do I add horizontal rule above total row using Stata 17 table + collect

    I am trying to format a table with frequencies and percentages for a single variable for export to LaTeX using the new Stata collect/table combination. I'm using Stata 17 on Windows.

    I'd like to add a horizontal rule all the way across on top of the "total"-row. (In general, I'd like to figure out how to put horizontal lines wherever I'd like, not just around the four levels of border_block.)

    By reading different sources (manual, Stata blog, Statalist), I’ve been able to put a line on top of the numbers, but I’d like it on top of the “Total” text as well. Is this possible?

    Below is an example of how far I got:

    Code:
    sysuse auto, clear
    collect clear
    
    table foreign, ///
        statistic(frequency)  ///
        statistic(percent)
    
    collect style cell result[percent], sformat("%s%%")
    collect style cell border_block, border(right, pattern(nil))
    collect style cell cell_type[item]#foreign[.m], border(top)
    
    collect preview
    Last edited by Rebecca Udsen; 18 Feb 2022, 03:07. Reason: Edited to add tags.

  • #2
    Playing around with collect and found your post. Is this what you're looking for?

    Code:
    sysuse auto, clear
    collect clear
    
    table foreign, ///
        statistic(frequency)  ///
        statistic(percent)
    
    collect style cell result[percent], sformat("%s%%")
    collect style cell border_block, border(right, pattern(nil))
    collect style cell foreign[.m], border(top)
    
    collect preview

    Comment

    Working...
    X