Announcement

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

  • Formatting Superheaders and Selective Borders using Collect

    Hello,

    I am having trouble formatting a table that I will need to repeat 50+ times and would like Stata to take care of the formatting as much as possible.

    I have been able to get most of what I need, however I am having trouble with two aspects:

    - Formatting the Super-headers: I would like the rows "Version1" and "Version2" to have a gray background color. In the example below, when I try to format the collection dimension, it formats the entire table. I cannot find a way to format just the header row for the collection dimension (Version1 and Version2)

    - Selective borders: I would like to have borders around each combination of coefficient and confidence interval. I can only figure out how to format it so no borders appear among the item cell type, or all of them. I can get most of the way there using the below code, but it 1) includes borders for non-results like the spacer and the collection super-header, and 2) doesn't extend to the row-headers to make boxes of the same size. Is there a way to do this?

    Thank you for your help:

    Code:
    collect clear
    sysuse auto, clear
    
    collect create Version1, replace
    
        collect _r_b _r_ci : reg price headroom trunk
        collect _r_b _r_ci : reg price headroom trunk weight length
    
    collect create Version2, replace
    
        collect _r_b _r_ci : reg price headroom trunk if foreign == 0
        collect _r_b _r_ci : reg price headroom trunk weight length if foreign == 0
        
    collect combine combined = Version1 Version2
    collect layout (collection[Version1]#colname[headroom]#result collection[Version1]#colname[trunk]#result collection[Version2]#colname[headroom]#result collection[Version2]#colname[trunk]#result) (cmdset)
    
    collect style header result, level(hide)
    collect style row stack, spacer
    
    collect stars _r_b _r_p .05 `"*"', attach(_r_b)
    collect style cell result[_r_ci], sformat("[%s]") cidelimiter(",")
    
    collect style cell , valign(center) nformat(%9.2f) 
    collect style cell cell_type[row-header], halign(left)
    collect style cell cell_type[column-header], halign(center)
    collect style cell cell_type[item], halign(center)
    
    collect style cell, border( all, pattern(none) )
    collect style cell result[_r_b] , border( top left right, pattern(single) )
    collect style cell result[_r_ci] , border( bottom left right, pattern(single) )
Working...
X