Announcement

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

  • Using collect command to display results by quartile

    I want to make a table that shows regression results for a bunch of dependent variables against the same independent variable by quartile groups something like this:
    Q1 Q2 Q3 Q4
    Dep var 1
    Dep var 2
    Dep var 3
    Mean of sample
    This is my example code:

    HTML Code:
    sysuse auto, clear
    xtile price_quart = price, n(4)
    
    collect clear 
    
    foreach var of varlist rep78 headroom trunk weight{
        bys price_quart: collect: reg `var' mpg
    }
    
    collect layout (colname#cmdset#result[_r_b _r_se]) (price_quart)
    This makes the values show up in individual row:
    Click image for larger version

Name:	sample.png
Views:	1
Size:	20.1 KB
ID:	1769929


    How can I get the same dependent variable values to be displayed in the same row?
    And is there a way to display the mean of price variable at the bottom by quartile?
Working...
X