Announcement

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

  • #16
    So round to the nearest 10 (in base 10). #12 shows that specifying a display format "%xx.0f" in esttab is equivalent to rounding to the nearest whole number. I am not sure if we are still talking matrices, but if so, you can divide the matrix by some multiple of 10 and use such a format, stating that amounts are in hundreds or in thousands. On the other hand, you can manipulate the matrices directly as below. With estimates in e(b), see the -transform- option of estout that will achieve this directly.


    Code:
    sysuse auto, clear
    mkmat price length disp in 1/20, mat(X)
    
    *START HERE (MATRIX TO OUTPUT IS NAMED "X")
    mat l X
    mat X= X/10
    mata: XR=round(st_matrix("X"), 1)
    mata: st_matrix("XR",XR)
    mat XR=XR*10
    mat colnames XR= `:colnames X'
    mat rownames XR= `:rownames X' 
    
    mat l XR
    esttab mat(XR, fmt(%13.0f)) using myfile.csv, replace nomtitle
    Res.:

    Code:
    . mat l X
    
    X[20,3]
                price        length  displacement
     r1          4099           186           121
     r2          4749           173           258
     r3          3799           168           121
     r4          4816           196           196
     r5          7827           222           350
     r6          5788           218           231
     r7          4453           170           304
     r8          5189           200           196
     r9         10372           207           231
    r10          4082           200           231
    r11         11385           221           425
    r12         14500           204           350
    r13         15906           204           350
    r14          3299           163           231
    r15          5705           212           250
    r16          4504           193           200
    r17          5104           200           200
    r18          3667           179           151
    r19          3955           197           250
    r20          3984           163            98
    
    
    .
    . mat l XR
    
    XR[20,3]
                price        length  displacement
     r1          4100           190           120
     r2          4750           170           260
     r3          3800           170           120
     r4          4820           200           200
     r5          7830           220           350
     r6          5790           220           230
     r7          4450           170           300
     r8          5190           200           200
     r9         10370           210           230
    r10          4080           200           230
    r11         11390           220           430
    r12         14500           200           350
    r13         15910           200           350
    r14          3300           160           230
    r15          5710           210           250
    r16          4500           190           200
    r17          5100           200           200
    r18          3670           180           150
    r19          3960           200           250
    r20          3980           160           100
    Last edited by Andrew Musau; 14 Apr 2023, 08:41.

    Comment


    • #17
      Thank you so much! I am curious if this will work with if my table is also reporting median, means and standard deviations? Also, is there a way to tell esttout to round a certain variable to base 10 if it is less than 1000 and base 100 if it is more than 1000?

      Comment


      • #18
        Provide a data example (see FAQ #12 for details).

        Comment

        Working...
        X