Announcement

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

  • Tabout 3 summary statistics transposing columns to rows

    Hi Statalist,

    I am using Stata 15 and I have a question related to tabout 3.

    I want to make a table (as a docx) with multiple continuous variables (age, duration of infection, etc) by a certain categorical variable (with three levels).

    I want the categorical variable to be presented as columns and all of the continuous variables as rows.

    However, the current version of tabout only seems to allow having the categorical variable in the column, and therefore all my continious variables are shown in the rows. This is not very handy for reporting in the manuscript.

    Does anyone knows a way (if in tabout) or a trick to make this changes?


    For example, now I get this:

    age yearIDU
    infection
    HIV 31 6.0
    HCV 29 1.8
    HBV 30 5.0

    But i want:
    HIV HCV HBV
    age
    yearIDU

    Any help is highly appreciated!!!

    Thanks, Daniela.


  • #2
    There is a sort of hack you can use here, though it's not perfect.

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . gen byte one = 1
    
    . tabout rep78 using temp1, replace
    
    Table output written to: temp1
    
    Repair Record 1978      No.
    1       2.0
    2       8.0
    3       30.0
    4       18.0
    5       11.0
    Total   69.0
    
    . tabout one rep78 using temp1, replace
    
    Table output written to: temp1
    
            Repair Record 1978                                      
    one     1       2       3       4       5       Total
            No.     No.     No.     No.     No.     No.
    1       2.0     8.0     30.0    18.0    11.0    69.0
    Total   2.0     8.0     30.0    18.0    11.0    69.0
    You might want to turn off the total option and also label the value of the row variable with something meaningful or a blank, like
    Code:
    label define one 1 ""
    label value one one
    Note: tabout was written by Ian Watson and is available from SSC.
    David Radwin
    Senior Researcher, California Competes
    californiacompetes.org
    Pronouns: He/Him

    Comment

    Working...
    X