asdocx table1: Report a single statistic


The table1 template of asdocx reports statistics in pairs in the format of firstStat (secondStat).  The default statistics for each type of variables are given below:
(1) Binary variables : Count (Percentages)
(2) Categorical variables : Count (Percentages)
(3) Continuous variables : Mean (95% confidence interval)

We can choose to report just a single statistic by using factor(), continuous(), or binary() options. These options are used specify the preferred statistics, either in pair or single. Therefore, when invoke factor(count %), we tell asdocx to report the pair of frequency counts and percentages. And when we invoke factor(%) or factor(count), we tell asdocx to report a single statistic.

 

Specify two statistics


Let’s start with reporting a pair of two statistics for the categorical variable agegrp .  Note the option factor(count %), I used it here just to show how this option can be used. Even if we do not use it, the default for factor variables is to report counts and percentages in pairs (The percentages are cell percentages. See how to report row and column percentages).

* Load example Data
webuse nhanes2b, clear

* Make table1 with asdocx
asdocx tabulate diabetes i.agegrp  , factor(count %) template(table1)  replace
Table 1: Demographics
Variables Not diabetic (n=9850) Diabetic (n = 499) Total (10349) P-value
Age group 0.00
20–29
2305 (22.27%) 15 (0.14%) 2320 (22.42%)
30–39
1600 (15.46%) 21 (0.20%) 1621 (15.66%)
40–49
1229 (11.88%) 42 (0.41%) 1271 (12.28%)
50–59
1219 (11.78%) 72 (0.70%) 1291 (12.47%)
60–69
2622 (25.34%) 238 (2.30%) 2860 (27.64%)
70+
875 (8.45%) 111 (1.07%) 986 (9.53%)

 

Specify one statistics – counts


To report just counts, we shall use factor(count) option.

asdocx tabulate diabetes i.agegrp  , factor(count %) template(table1)  replace
Table 1: Demographics
Variables Not diabetic (n=9850) Diabetic (n = 499) Total (10349) P-value
Age group 0.00
20–29
2305 15 2320
30–39
1600 21 1621
40–49
1229 42 1271
50–59
1219 72 1291
60–69
2622 238 2860
70+
875 111 986

Specify one statistics – percentages


asdocx tabulate diabetes i.agegrp  , factor(%) template(table1)  replace
Table 1: Demographics
Variables Not diabetic (n=9850) Diabetic (n = 499) Total (10349) P-value
Age group 0.00
20–29
22.27% 0.14% 22.42%
30–39
15.46% 0.20% 15.66%
40–49
11.88% 0.41% 12.28%
50–59
11.78% 0.70% 12.47%
60–69
25.34% 2.30% 27.64%
70+
8.45% 1.07% 9.53%