Announcement

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

  • Adding a column of p-value to table

    Hello, I want to add a p-value column to this table where the p-value from relevant tests (i.e., for 'age' from t-test and for 'gender' and 'course' from chi-square test) will be displayed. What is the way to do it?

    Code:
    -----------------------------------------
                       Substance Use        
                    No               Yes    
    -----------------------------------------
    Age       22.1     (1.9)   23.6     (2.1)
                                            
    Gender                                  
      Male     413   (42.4%)    126   (81.8%)
      Female   562   (57.6%)     28   (18.2%)
    Course                                  
      MBBS     922   (94.6%)    146   (94.8%)
      BDS       53    (5.4%)      8    (5.2%)
    -----------------------------------------
    The code I used was:
    Code:
    table (var) (substanceuse), statistic(mean age) statist (sd age) statistic(fvfrequency gender curriculum ) statistic(fvpercent gender curriculum ) nototals
    collect recode result mean = column1 sd=column2 fvfrequency = column1 fvpercent   = column2
    collect layout (var) (substanceuse#result[column1 column2])
    collect style cell var[gender curriculum ]#result[column1], nformat(%6.0fc)
    collect style cell var[gender curriculum ]#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 style header result, level(hide)
    collect style row stack, nobinder spacer
    collect style cell border_block, border(right, pattern(nil))
    collect preview
    Thank you!

    Stata 17

  • #2
    see the fourth in Chuck Huber's set of blogs: https://blog.stata.com/2021/08/24/cu...istical-tests/

    Comment


    • #3
      Originally posted by Rich Goldstein View Post
      see the fourth in Chuck Huber's set of blogs: https://blog.stata.com/2021/08/24/cu...istical-tests/
      Thank you for your reply. I have gone through it, but I couldn't grasp how to incorporate p-values from multiple types of tests (i.e., t-test, ANOVA, chi-square test) since Mr. Huber presented the example with only p-values from t-test. Also in the example summary statistics (mean and SD) was derived from the scalars of the t-test. But I couldn't figure out how to do that in the case of chi-square test or ANOVA.

      I hope you can help me out in this case. Thank you.

      Stata 17

      Comment

      Working...
      X