I recently attended the webinar on customizable tables in Stata 17. One of the sample tables used in the webinar, as shown below in slighted modified, demonstrates the power of the new table/collect command.
Code:
-------------------------------------------------------
Hypertension
No Yes Total
-------------------------------------------------------
Sex
Male 2,611 43.7% 2,304 52.7% 4,915 47.5%
Female 3,364 56.3% 2,072 47.3% 5,436 52.5%
Race
White 5,317 89.0% 3,748 85.6% 9,065 87.6%
Black 545 9.1% 541 12.4% 1,086 10.5%
Other 113 1.9% 87 2.0% 200 1.9%
-------------------------------------------------------
Equally common is the need to show row percentages across the column variable, in this instance, the yes/no values of hypertension. Alternatively, in a slightly different arrangement, a table that combines the results from multiple tabstat results, showing total case count, count of cases with the yes value, and percent with yes, all properly formatted, would be very helpful as well. I searched without success any postings related this type of table using the new Stata 17 command table/collect. Shown below is the log result from tabstat using the same dataset in the webinar.
Code:
. webuse nhanes2, clear
. tabstat highbp, by(sex) s(count sum mean)
Summary for variables: highbp
Group variable: sex (Sex)
sex | N Sum Mean
-------+------------------------------
Male | 4915 2304 .4687691
Female | 5436 2072 .3811626
-------+------------------------------
Total | 10351 4376 .4227611
--------------------------------------
. tabstat highbp, by(race) s(count sum mean)
Summary for variables: highbp
Group variable: race (Race)
race | N Sum Mean
-------+------------------------------
White | 9065 3748 .4134584
Black | 1086 541 .4981584
Other | 200 87 .435
-------+------------------------------
Total | 10351 4376 .4227611
--------------------------------------
Best,
Ron
0 Response to Using the new table collect row percentages for multiple factor variables
Post a Comment