Announcement

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

  • Add horizontal line between rows in a collect environment

    I am trying to run multiple regressions across different specifications and I need to export the results where the dependent variables are rows instead of columns and independent variables in subgroups are columns. I am using Stata's collect commands to create this customized table.

    For example:

    Code:
    sysuse auto.dta 
    collect drop _all
    collect create price
    quietly: collect: reg price mpg rep78 
    quietly: collect: reg price mpg rep78 
    
    collect create trunk
    quietly: collect: reg trunk mpg rep78 if foreign==1
    quietly: collect: reg trunk mpg rep78 if foreign==1
    
    collect combine new= price trunk
    collect layout  (coleq#result[_r_b _r_se]) (cmdset#colname[mpg rep78] extra)
    
    
    collect stars _r_p 0.01 "***" 0.05 "** " 0.1 "* ", attach(_r_b) shownote
    
    collect style row stack, spacer delimiter(" x ")
    
    collect label levels cmdset 1 "Pooled" 2 "Foreign", modify
    
    collect style cell cell_type[item column-header], halign(center)
    collect style cell, nformat(%5.3f)
    collect style cell border_block, border(right, pattern(nil))
    collect style cell result[_r_se], sformat("(%s)")
    collect style header result, level(hide)
    collect style column, dups(center)
    
    collect preview
    gives me the following result:

    Code:
    ---------------------------------------------------------------------------------------
                                       Pooled                           Foreign            
                          Mileage (mpg) Repair record 1978 Mileage (mpg) Repair record 1978
    ---------------------------------------------------------------------------------------
    Price                  -271.643***       666.957*       -271.643***       666.957*     
                             (57.771)        (342.356)        (57.771)        (342.356)    
                                                                                           
    Trunk space (cu. ft.)     -0.098           0.368           -0.098           0.368      
                             (0.121)          (1.061)         (0.121)          (1.061)     
    ---------------------------------------------------------------------------------------
    *** p<.01, ** p<.05, * p<.1
    I want to add a horizontal line between the price model and trunk space model but adding the following code adds a new empty row that I don't need.

    Code:
     
    collect style cell coleq[trunk], border(top, pattern(single))
    
    ---------------------------------------------------------------------------------------
                                       Pooled                           Foreign            
                          Mileage (mpg) Repair record 1978 Mileage (mpg) Repair record 1978
    ---------------------------------------------------------------------------------------
    Price                  -271.643***       666.957*       -271.643***       666.957*     
                             (57.771)        (342.356)        (57.771)        (342.356)    
    ---------------------------------------------------------------------------------------
                                                                                           
    ---------------------------------------------------------------------------------------
    Trunk space (cu. ft.)     -0.098           0.368           -0.098           0.368      
    ---------------------------------------------------------------------------------------
                             (0.121)          (1.061)         (0.121)          (1.061)     
    ---------------------------------------------------------------------------------------
    *** p<.01, ** p<.05, * p<.1
    Is there a cleaner way to get a horizontal line and some additional text as a row header?
Working...
X