Announcement

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

  • Label column in estimable table

    I am trying to build a customisable table:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte age int(sbp hr) double si byte transfusion
    48 152  83 .5460526315789473 1
    15 124 130 1.048387096774194 1
    91 143 158 1.104895104895105 1
    26  90 119 1.322222222222222 1
    46  68 133 1.955882352941176 1
    40  86 105 1.220930232558139 1
    85  96  68 .7083333333333334 1
    25  60 152 2.533333333333333 1
    44 103 109 1.058252427184466 1
    30  60  92 1.533333333333333 1
    16 144 147 1.020833333333333 1
    49  60  84               1.4 1
    30 147  62 .4217687074829932 1
    60  90  90                 1 1
    80   . 102                 . 1
    60 180  80 .4444444444444444 1
    40 157 167 1.063694267515924 1
    68  80 120               1.5 1
    54  70  75 1.071428571428571 1
    57 144  79 .5486111111111112 1
    45  80  75             .9375 1
    21  66 121 1.833333333333333 1
    89 125 108              .864 1
    32   .   .                 . 1
    25  80 120               1.5 1
    end
    label values transfusion yn
    label def yn 1 "Yes", modify
    label var age "Age / Years"
    label var sbp "Systolic Blood Pressure / mm Hg"
    label var hr "Heart rate / bpm"
    label var si "Shock Index"
    label var transfusion "transfusion 1-yes 0-no"
    Code:
    collect clear
    table (var) (transfusion),              ///
            stat(mean age hr sbp si) stat(sd age hr sbp si) ///
            stat(p50 age hr sbp si) stat(iqr age hr sbp si)
    collect dims
    collect levelsof result
    collect recode result   ///
            mean = column1  ///
            sd = column2    ///
            p50 = column3   ///
            iqr = column4
    collect label dim transfusion "Transfusion", modify
    collect layout (var) (transfusion#result[column1 column2 column3 column4])
    *collect style header result, level(hide)
    collect style row stack, nobinder spacer
    collect style cell var[age hr sbp si]#result[column1 column2 column3 column4], nformat(%6.1f)
    collect preview
    which gives me:
    Code:
    . collect preview
    
    ----------------------------------------------------------------------------------------------------------------
                                    |                                   Transfusion                                 
                                    |                   Yes                                    Total                
                                    |  column1   column2   column3   column4   column1   column2   column3   column4
    --------------------------------+-------------------------------------------------------------------------------
    Age / Years                     |     47.0      22.5      45.0      30.0      47.0      22.5      45.0      30.0
    Heart rate / bpm                |    107.5      29.8     106.5      44.0     107.5      29.8     106.5      44.0
    Systolic Blood Pressure / mm Hg |    104.6      37.2      90.0      74.0     104.6      37.2      90.0      74.0
    Shock Index                     |      1.2       0.5       1.1       0.6       1.2       0.5       1.1       0.6
    ----------------------------------------------------------------------------------------------------------------

  • #2
    Sorry - sent prematurely.
    I would like to rename column1~column4 as mean, sd, p50, iqr but I cannot figure out how to do it.
    Any advice gratefully received.
    Thank you,
    Eddy

    Comment

    Working...
    X