Announcement

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

  • estout/esttab multiline refcat label without LateX

    Hi,

    I am using Ben Jann's estout command to produce a regression table, like this:

    Code:
    ssc install estout
    
    sysuse auto
    
    reg price i.foreign
    
    estout, nobase refcat(1.foreign "Car type: Ref. Domestic") label
    I would like to have the reference category label split into two lines: "Car type:" and "Ref. Domestic".
    I know this is possible when exporting the table to LateX. However, I would like to export the table as a CSV file.

    So far, all of my attempts to do this, as well as consulting estout's help file and searching the web, were unsuccessful.

    For example, the use of two hierarchies of quotation marks does not work here:

    Code:
    estout, nobase refcat(1.foreign `" "Car type:""Ref. Domestic" "') label
    Is there any way to achieve this?

    Thank you and kind regards

    Sebastian

  • #2
    Elsewhere, it has been noted that ASC11 Chr(10) and Chr(13) can be used to create line breaks. This appears to be the case here too. For a description of these characters, see https://www.petefreitag.com/item/863.cfm.

    Code:
    sysuse auto
    reg price i.foreign
    estout, nobase refcat(1.foreign "Car type:`=char(13)'`=char(10)'Ref. Domestic") label noabbrev substitute("ref." "") mlab(none)
    Res.:

    Code:
    . estout, nobase refcat(1.foreign "Car type:`=char(13)'`=char(10)'Ref. Domestic") label noabbrev substitute("ref."
    >  "") mlab(none)
    
    ---------------------------------
                                    b
    ---------------------------------
    Car type:
    Ref. Domestic         
    Foreign                  312.2587
    _cons                    6072.423
    ---------------------------------

    Comment


    • #3
      Thank you, Andrew, this seems to work! Do you have any idea, why the "ref." is left aligned now? Is there a way to correct this?

      Code:
      estout, nobase refcat(1.foreign "Car type:`=char(10)'Domestic") label
      
      ---------------------------------
                                      .
                                      b
      ---------------------------------
      Car type:
      Domestic           ref.
      Foreign                  312.2587
      _cons                    6072.423

      Comment


      • #4
        Must be the length of the text that precedes it prior to introducing a line break. If you have many reference categories defined, you will need to fiddle with the lengths of the text within -refcat()- to achieve uniformity. But here is a workaround using -substitute()-

        Code:
        sysuse auto
        reg price i.foreign
        esttab, nobase label refcat(1.foreign "Car type:`=char(10)'Domestic") varwidth(30) substitute(ref. "          ref.")
        Res.:

        Code:
        . esttab, nobase label refcat(1.foreign "Car type:`=char(10)'Domestic") varwidth(30) substitute(ref. "          r
        > ef.")
        
        ----------------------------------------------
                                                (1)   
                                              Price   
        ----------------------------------------------
        Car type:
        Domestic                               ref.   
        
        Foreign                               312.3   
                                             (0.41)   
        
        Constant                             6072.4***
                                            (14.76)   
        ----------------------------------------------
        Observations                             74   
        ----------------------------------------------
        t statistics in parentheses
        * p<0.05, ** p<0.01, *** p<0.001
        
        .
        Last edited by Andrew Musau; 08 Feb 2022, 04:41.

        Comment


        • #5
          Perfect, thank you, Andrew!
          Sebastian

          Comment

          Working...
          X