asdocx: Export from Stata to Word, Excel, LaTeX & HTML › Forums › asdocx Forum › Adding column to table
Tagged: asdocx, customized table, flexmat, paired sample ttest
-
AuthorPosts
-
Hello
I have a dataset with variables that were asked twice, but with different references. I want to compilate a table of summary statistics comparing the following statistics between two versions of the variable: count mean sd var cv p50 skewness. Also I want to do an paired ttest between the two versions of the variable and report the two-tailed p-value in a column added to the table.
questions:
Is there some way I can write a code using docx comparing the two variables directly in the table by ex putting the statistics side by side?How can I add a column with the p-value from the paired ttest between the two versions of the variable?
Hello Rune
Welcome to asdocx forum. I think you need some sort of a customized table, for which flexmat is a good choice. flexmat is part of the asdocx package and it is already installed if you have asdocx. There are several examples where I show how to make tables with flexmat, or modify tables that are already made by asdocx. References to these resources are given below. Please note the optiontranspose, it changes the table layout from wide to long.1. Introduction to flexmat : [ view post here ]
2. Add a Stata matrix to existing asdocx table [view post here ]
3. Create tables by cells, rows, or columns [ YouTube Video ]
To give a quick start for your desired solution, let me present the following code:
* Load some example data sysuse bpwide * Create statistics with asdocx asdocx sum bp_before bp_after, stat(count mean sd var p50 skewness) replace transpose 0 |1 2 3 ----+----------------------------------------------------------------------------- 1 |Variables bp before bp after ----+----------------------------------------------------------------------------- 2 |N 120 120 3 |Mean 156.45 151.35833 4 |Std. Dev. 11.38985 14.17762 5 |variance 129.72857 201.00497 6 |Median 154.5 149.5 7 |skewness 0.54729 0.38843 ---------------------------------------------------------------------------------- * Conduct a two sample t-test ttest bp_before == bp_after * The p-value from the t-test can now be appended to row 8 of the table created by asdoc flexmat addrow, data(p-value, `r(p)') row(8) dec(4) Table: Summary Statistics 0 |1 2 3 ----+----------------------------------------------------------------------------- 1 |Variables bp before bp after ----+----------------------------------------------------------------------------- 2 |N 120 120 3 |Mean 156.45 151.35833 4 |Std. Dev. 11.38985 14.17762 5 |variance 129.72857 201.00497 6 |Median 154.5 149.5 7 |skewness 0.54729 0.38843 8 |p-value 0.0011 ---------------------------------------------------------------------------------- * Export the new table to MS Word asdocx exportThank you Dr. Shah!
-
AuthorPosts
- You must be logged in to reply to this topic.