Announcement

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

  • Displaying factor variable labels in etable

    I wish to have finer control over how etable displays factor variables, specifically dummy variables. Let me demonstrate what is hanging me up.

    Code:
    . sysuse auto
    (1978 automobile data)
    
    . qui regress price mpg i.foreign
    
    . etable
    
    ---------------------------------
                              price  
    ---------------------------------
    Mileage (mpg)            -294.196
                             (55.692)
    Car origin                      
      Foreign                1767.292
                            (700.158)
    Intercept               11905.415
                           (1158.634)
    Number of observations         74
    ---------------------------------
    I would like to get rid of the line "Car origin", so the table would look like:

    Code:
    ---------------------------------
                              price  
    ---------------------------------
    Mileage (mpg)            -294.196
                             (55.692)
      Foreign                1767.292
                            (700.158)
    Intercept               11905.415
                           (1158.634)
    Number of observations         74
    ---------------------------------
    I've figured out how to do so using collect and table. But my co-author is less familiar with Stata and I'd like to give her an option that leverages the simplicity of etable.

    One solution I've discovered is to not add the "i." prefix. But, that doesn't work when using margins, especially if there are interactions. Also, it just seems (to me) better practice to be explicit in marking factor variables.

    I've searched broadly for solutions, but hopefully someone knows the solution that has eluded me.

    Thanks.
    Last edited by ghoetker; 04 Dec 2025, 20:55.
    _______________________________________

    Glenn Hoetker
    Professor in Business Strategy

    Melbourne Business School, University of Melbourne
    200 Leicester Street, Carlton, Victoria 3053, Australia
    Email: [email protected]

    I acknowledge the Traditional Owners of the land on which I work, the Wurundjeri people of the Kulin Nations, and pay my respects to their Elders, past and present.

  • #2
    There is no etable option that does what you describe.

    Your only option is to hide each factor variable's title with command collect style header, such as
    Code:
    collect style header foreign, title(hide)
    In your example, that results in the following table.
    Code:
    . collect preview
    
    ---------------------------------
                              price
    ---------------------------------
    Mileage (mpg)            -294.196
                             (55.692)
    Foreign                  1767.292
                            (700.158)
    Intercept               11905.415
                           (1158.634)
    Number of observations         74
    ---------------------------------

    Comment


    • #3
      Thank you for the quick and helpful answer. Given the jump in complexity between etable and collect/table, I hope adding this functionality might be considered for the future.
      _______________________________________

      Glenn Hoetker
      Professor in Business Strategy

      Melbourne Business School, University of Melbourne
      200 Leicester Street, Carlton, Victoria 3053, Australia
      Email: [email protected]

      I acknowledge the Traditional Owners of the land on which I work, the Wurundjeri people of the Kulin Nations, and pay my respects to their Elders, past and present.

      Comment

      Working...
      X