Announcement

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

  • Creating Table 1 with p-values--Table and Collect commands STATA 17

    Hello everyone,
    I am creating Table 1 for a paper and was able to create a comparison between males and females on age (continous) and smoking status (binary). I am just stuck on adding a column for p-values after "Total". Here is my command:

    ================================================== ====
    // Table 1 comparing males/females on age and smoking status.
    collect clear
    table (var) (gender), ///
    statistic(mean age ) ///
    statistic(sd age ) ///
    statistic(fvfrequency smoking) ///
    statistic(fvpercent smoking) ///
    statistic(mean age ) ///
    statistic(sd age )

    collect label dim gender "Sex", modify
    collect label levels gender 1 "Male" 2 "Female"
    collect recode result fvfrequency = column1 ///
    fvpercent = column2 ///
    mean = column1 ///
    sd = column2
    collect layout (var) (gender#result[column1 column2])
    collect style header result, level(hide)
    collect style row stack, nobinder spacer
    collect style cell border_block, border(right, pattern(nil))
    collect style cell var[smoking]#result[column1], nformat(%6.0fc)
    collect style cell var[]#result[column2], ///
    nformat(%6.1f) sformat("%s%%")
    collect style cell var[age ]#result[column1 column2], ///
    nformat(%6.1f)
    collect style cell var[age ]#result[column2], ///
    sformat("(%s)")
    collect preview

    collect export Table1.xls, as(xls) replace
    ============================================

    Any help is appreciated

    Suliman

  • #2
    Dear Suliman,
    Sincerely regards,
    Abdullah Algarni
    [email protected]

    Comment

    Working...
    X