Announcement

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

  • Column headers with Greek symbols using etable command

    I was wondering how I can add Greek symbols using the etable command.
    Below, I have included an example of the type of latex table that I would like to construct.

    However, instead of the column header being "Systolic blood pressure", I would like the column header to be
    "\% \Delta Systolic blood pressure." I have tried different methods but none has worked.

    use https://www.stata-press.com/data/r18/nhanes2l

    quietly: regress bpsystol i.sex weight
    estimates store model1
    quietly: regress diabetes i.sex i.agegrp weight
    estimates store model2
    etable, est(model1 model2)
    etable, replay eqrecode(bpsystol = xb diabetes = xb) column(dvlabel)
    collect style tex , nobegintable
    collect export example.tex, tableonly replace

  • #2
    Thanks for the reproducible example. You should do this using collect. See

    Code:
    help collect label
    Code:
    use https://www.stata-press.com/data/r18/nhanes2l
    quietly: regress bpsystol i.sex weight
    estimates store model1
    quietly: regress diabetes i.sex i.agegrp weight
    estimates store model2
    etable, est(model1 model2)
    etable, replay eqrecode(bpsystol = xb diabetes = xb) column(dvlabel)
    *CHECK NAMED DIMENSIONS AND THEIR LEVELS
    collect dims
    collect levelsof etable_dvlabel
    *RELABEL (UNICODE CHARACTERS ALLOWED)
    collect label levels etable_dvlabel 1 "% `=ustrunescape("\u0394")' Systolic blood pressure" 2 "Diabetes", modify
    Res.:

    Code:
    . collect preview
    
    -----------------------------------------------------------
                           % Δ Systolic blood pressure Diabetes
    -----------------------------------------------------------
    Sex                                                        
      Female                                     1.420    0.021
                                               (0.475)  (0.004)
    Weight (kg)                                  0.452    0.001
                                               (0.015)  (0.000)
    Age group                                                  
      30–39                                               0.002
                                                        (0.007)
      40–49                                               0.020
                                                        (0.007)
      50–59                                               0.042
                                                        (0.007)
      60–69                                               0.073
                                                        (0.006)
      70+                                                 0.105
                                                        (0.008)
    Intercept                                   97.634   -0.089
                                               (1.246)  (0.012)
    Number of observations                       10351    10349
    -----------------------------------------------------------
    
    .

    Comment


    • #3
      Thanks! However, I should have specified that the table needs to go in a LateX document so the special character for delta
      `=ustrunescape("\u0394")' is not going to be readable. It needs to be $\Delta$.

      Comment


      • #4
        So have that!

        Code:
        collect label levels etable_dvlabel 1 "\% $\Delta$ Systolic blood pressure", modify
        My point is to show how you can modify the label.

        Comment


        • #5
          I was able produce the table I need using a prior post by Andrew Musau and the estabb command the substitute option. However, I was wondering if there is a way to do that with etable.

          Comment


          • #6
            The command
            collect label levels etable_dvlabel 1 "\% $\Delta$ Systolic blood pressure", modify Is not going to work since I lead to extra "" that create problems in Latex. It seems to me that one needs some command to get rid of these like the command
            substitute("\_" "_")
            which you discuss in https://www.statalist.org/forums/for...n-extra-to-tex

            Comment


            • #7
              Try this:

              Code:
              collect label levels etable_dvlabel 1 "% \(\Delta\) Systolic blood pressure", modify
              You can use

              Code:
              \( \)
              instead of

              Code:
              $ $
              for inline math mode in LaTeX.

              Res.:

              Code:
              \begin{table}[!h]
              
              \centering
              
              \begin{tabular}{lll}
              
              \cline{1-3}
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{c}{\% \(\Delta\) Systolic blood pressure} &
              
              \multicolumn{1}{c}{Diabetes status} \\
              
              \cline{1-3}
              
              \multicolumn{1}{l}{Sex} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{} \\
              
              \multicolumn{1}{l}{\hspace{1em}Female} &
              
              \multicolumn{1}{r}{1.420} &
              
              \multicolumn{1}{r}{0.021} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{(0.475)} &
              
              \multicolumn{1}{r}{(0.004)} \\
              
              \multicolumn{1}{l}{Weight (kg)} &
              
              \multicolumn{1}{r}{0.452} &
              
              \multicolumn{1}{r}{0.001} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{(0.015)} &
              
              \multicolumn{1}{r}{(0.000)} \\
              
              \multicolumn{1}{l}{Age group} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{} \\
              
              \multicolumn{1}{l}{\hspace{1em}30–39} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{0.002} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{(0.007)} \\
              
              \multicolumn{1}{l}{\hspace{1em}40–49} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{0.020} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{(0.007)} \\
              
              \multicolumn{1}{l}{\hspace{1em}50–59} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{0.042} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{(0.007)} \\
              
              \multicolumn{1}{l}{\hspace{1em}60–69} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{0.073} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{(0.006)} \\
              
              \multicolumn{1}{l}{\hspace{1em}70+} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{0.105} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{} &
              
              \multicolumn{1}{r}{(0.008)} \\
              
              \multicolumn{1}{l}{Intercept} &
              
              \multicolumn{1}{r}{97.634} &
              
              \multicolumn{1}{r}{-0.089} \\
              
              \multicolumn{1}{l}{} &
              
              \multicolumn{1}{r}{(1.246)} &
              
              \multicolumn{1}{r}{(0.012)} \\
              
              \multicolumn{1}{l}{Number of observations} &
              
              \multicolumn{1}{r}{10351} &
              
              \multicolumn{1}{r}{10349} \\
              
              \cline{1-3}
              
              \end{tabular}
              
              \end{table}
              Last edited by Andrew Musau; 01 Jan 2025, 15:06.

              Comment


              • #8
                Andrew, this works perfectly. Thanks you for your patience!!!

                Comment

                Working...
                X