Announcement

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

  • Bold row header in etable

    Hi all,

    I am trying to make some changes in a etable, my goal is get variables header with bold font:


    Code:
    putdocx begin
    
    webuse nhanes2l
    logit highbp c.age##i.sex i.diabetes bmi
    est store logit
    
    etable, column(command) estimates(logit ) mstat(N, nformat(%9.0g))  mstat(aic, nformat(%9.3f)) mstat(bic, nformat(%9.3f)) mstat(r2_p, nformat(%9.3f)) showstars  eqrecode(eq1 = modalidad_dicotomica1)
    putdocx collect
    I did try with:

    Code:
    etable, column(command) estimates(logit ) mstat(N, nformat(%9.0g))  mstat(aic, nformat(%9.3f)) mstat(bic, nformat(%9.3f)) mstat(r2_p, nformat(%9.3f)) showstars  eqrecode(eq1 = modalidad_dicotomica1)
    
    collect style cell vargrp#cell_type[row-header], font(,bold)
    collect style cell vargrp2#cell_type[row-header], font(,bold)
    
    #or:
    
    collect style cell vartype#cell_type[row-header], font(,bold)
    
    putdocx collect
    But I failed.
    Click image for larger version

Name:	Sin título.png
Views:	1
Size:	52.0 KB
ID:	1784819





    I did check some older post similar using dtable:

    https://www.statalist.org/forums/for...t-their-levels

    Thanks in advance
    Last edited by Rodrigo Badilla; 12 Feb 2026, 16:22.

  • #2
    One could argue that row headers apply only to factor variables; however, in your illustration you are also bolding the labels of the continuous variables. With etable's default settings, you can either bold all variable names and labels or exclude some of them. To distinguish between continuous and factor variables, you would need to use collect and construct the table produced by etable accordingly. Since your factor variables are binary, I would simply label the factor variable using the label of the displayed level, rather than including both the variable name and its label. The alternatives discussed are outlined below.

    Code:
    putdocx begin 
    
    webuse nhanes2l
    logit highbp i.sex##c.age i.diabetes bmi
    est store logit
    
    etable, column(command) estimates(logit ) mstat(N, nformat(%9.0g))  mstat(aic, nformat(%9.3f)) mstat(bic, nformat(%9.3f)) mstat(r2_p, nformat(%9.3f)) showstars  eqrecode(eq1 = modalidad_dicotomica1)
    *CHECK LAYOUT OF ETABLE
    
    collect layout
    
    *BOLDEN VARNAMES AND VARLABELS 
    collect style cell colname#cell_type[row-header], font(,bold)
    
    *UNBOLDEN SOME VARNAMES, E.G., THE INTERCEPT 
    collect style cell colname[_cons]#cell_type[row-header], font(,nobold)
    
    *FIRST TABLE
    putdocx collect
    
    *RELABEL BINARY VARIABLES TO DISPLAYED LEVELS
    collect label levels colname sex "Female", modify
    collect label levels colname diabetes "Diabetic", modify
    
    *HIDE BINARY VARIABLES DISPLAYED LEVELS
    collect style header sex diabetes, level(hide)
    
    *SECOND TABLE
    putdocx collect
    
    putdocx save mytable, replace
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	36.2 KB
ID:	1784840

    Comment


    • #3
      Thanks Andrew Musau, works great!
      Regards
      Rodrigo

      Comment

      Working...
      X