The table 1 template


Introduction


The table1 template is an asdocx package that creates “Table 1”, i.e., patient baseline characteristics table commonly found in biomedical research papers. The template can summarize different types of variables such as continuous and categorical variables in a single table.

 

How to Use it


The template is free. However, it requires asdocx package, that is currently available at 80% discount for a limited time. The template file is installed automatically when you install asdocx.

After installation of the template, you can use the template as shown below.

Syntax

asdocx tab treatvar basevars, factor(stats) continuous(stats) 
       binary(stats) template(table1) report(cat) cell row col 

 

Syntax Details


The syntax starts with the keywords asdocx tab.

The treatvar is the treatment variable, the variable that holds information of the treatment group and placebo groups.

The basevars are all other variables that represent the basic characteristics of the participants.

Option template(table1)  invokes the table1 template.

The option report(cat) allows you to specify a specific category of a categorical variable to report in your output. By default, all categories are included in the report. For example, when working with a binary variable, you can use this option to only report one category (e.g. category 1) and exclude the other (e.g. category 0). It’s worth noting that even though the output may only show one category, all categories are still used in the calculation of relevant statistics.

 

A Simple Example

* Load example dataset
use http://fintechprofessor.com/asdocxAddins/table1.dta, clear

* Make table 1 using the template(table1) option
asdocx tab immigrant bone_arthritis bone_backspin              /// 
       bone_backother bone_neck bone_fibro bone_lupus         /// 
       bone_ehlers bone_deform bone_amp bone_burn nervous_ms  ///
       nervous_seizure nervous_park nervous_stroke           /// 
       other_otherhealth other_anyother ,                   /// 
       template(table1) table_layout(autofit) replace

In the above example, the variable immigrant is the treatvar and all other variables are basevars. After comma, option template(table1) causes asdocx to use the table1 template. The table_layout(autofit) creates a table with tight autofit of contents. The above code should generate the following table.

Table 1: Demographics
Variables Non-Immigrant (n=670) Immigrant (n = 108) Total (778) P-value
Arthritis 0.27
No arthritis
95 (13.07%) 11 (1.51%) 106 (14.58%)
Arthritis
532 (73.18%) 89 (12.24%) 621 (85.42%)
Back pain due to spinal stenosis 0.09
No back pain due to spinal st~
609 (83.77%) 100 (13.76%) 709 (97.52%)
Back pain due to spinal sten~
18 (2.48%) 0 (0.00%) 18 (2.48%)
Back pain due to other causes .
Back pain due to other causes
670 (86.12%) 108 (13.88%) 778 (100.%)
Neck pain 0.24
No neck pain
536 (73.73%) 81 (11.14%) 617 (84.87%)
Neck pain
91 (12.52%) 19 (2.61%) 110 (15.13%)
Fibromyalgia 0.68
No fibromyalgia
610 (83.91%) 98 (13.48%) 708 (97.39%)
Fibromyalgia
17 (2.34%) 2 (0.28%) 19 (2.61%)
Lupus 0.51
No lupus
624 (85.83%) 99 (13.62%) 723 (99.45%)
Lupus
3 (0.41%) 1 (0.14%) 4 (0.55%)
Ehlers-Danlos Syndrome 0.69
No Ehlers-Danlos syndrome
626 (86.11%) 100 (13.76%) 726 (99.86%)
Ehlers-Danlos Syndrome
1 (0.14%) 0 (0.00%) 1 (0.14%)
Deformity of limb 0.42
No deformity of limb
623 (85.69%) 100 (13.76%) 723 (99.45%)
Deformity of limb
4 (0.55%) 0 (0.00%) 4 (0.55%)
Amputation of limb 0.14
No amputation of limb
626 (86.11%) 99 (13.62%) 725 (99.72%)
Amputation of limb
1 (0.14%) 1 (0.14%) 2 (0.28%)
Severe burn 0.57
No severe burn
625 (85.97%) 100 (13.76%) 725 (99.72%)
Severe burn
2 (0.28%) 0 (0.00%) 2 (0.28%)
Multiple sclerosis 0.51
No multiple sclerosis
624 (85.83%) 99 (13.62%) 723 (99.45%)
Multiple sclerosis
3 (0.41%) 1 (0.14%) 4 (0.55%)
Seizure disorder 0.37
No seizure disorder
622 (85.56%) 100 (13.76%) 722 (99.31%)
Seizure disorder
5 (0.69%) 0 (0.00%) 5 (0.69%)
Parkinson’s Disease .
No Parkinson’s disease
627 (86.24%) 100 (13.76%) 727 (100%)
Parkinson’s Disease
. (.%) . (.%) . (.%)
Stroke (or effects of a prior st~ 0.84
No stroke (or effects of a prior
622 (85.56%) 99 (13.62%) 721 (99.17%)
Stroke (or effects of a prior
5 (0.69%) 1 (0.14%) 6 (0.83%)
Other health problem 0.86
No other health problem
593 (81.57%) 95 (13.07%) 688 (94.64%)
Other health problem
34 (4.68%) 5 (0.69%) 39 (5.36%)
Any other serious health problems 0.16
No other serious health prob~
399 (51.29%) 72 (9.25%) 471 (60.54%)
Any other serious health pro~
271 (34.83%) 36 (4.63%) 307 (39.46%)

 

Choosing Statistics


Table1 template allows different statistics with categorical / factor variables, continuous variables, and binary variables. The allowed statistics are given below:

 

Option


Details


mean Mean of the variable
sd Standard deviation of the variables
ci 95% Confidence interval
n Counts
N Counts
frequency Counts
percentage Count as Percentage of total *
% Count as percentage of total
perc Count as percentage of total
p1 First percentile
p5


5th percentile


*The default is to report cell percentages. Option row or col can be used to report row or column percentages.

 

The statistics presented in the above table can be selectively used with categorical, binary, and continuous variables. 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)

Binary and continuous variables are identified internally by asdocx. To declare a variable as categorical, we need to add i. as a prefix to the variable name. Two statistics can be reported with each type of variables. The first statistic is accompanied by the second one in brackets. Therefore, if we were to report frequency counts and percentages with categorical variable ed, we would write it as i.ed and also add the option cat(N %) or cat(n %) or cat(count perc). Let’s also report mean and confidence interval with continuous variables, therefore, use the option continuous(mean ci).

Example of Choosing Statistics

* Load example dataset
use http://fintechprofessor.com/asdocxAddins/svy.dta, clear

asdocx tab back bskin wskin i.ed, factor(N %) continuous(mean ci) ///
       template(table1) table_layout(autofit) replace

 

asdocx table1 choosing statistics

Using it with Survey prefix svy:


Using template table1 with survey data is not much different than using any other Stata command with the svy: prefix. As a first step, declare the data as survey data and then add the svy: prefix before the tab word. Then all the statistics reported by template1 will have survey weights. See the following example

* Load example dataset
use http://fintechprofessor.com/asdocxAddins/svy.dta, clear

* set the survey parameters
svyset SECLUSTR [pweight=NSALWTCT], strata(SESTRAT)

asdocx svy: tab back bskin wskin i.ed, factor(N %) continuous(mean ci) ///
       template(table1) table_layout(autofit) replace

 

asdocx table1 choosing statistics

 

More Examples


The default is to report cell percentages. If percentages need to be based on column total or row total, then option col or row must be used. The following two examples show this.

Report column percentages

Report row percentages

svy data : factor variables

Treatvar has multiple categories

Order asdocx


Yearly license of asdocx is available at $9.99. Its life-time license is available at $49.99. With the asdocx membership, you get :

  • Life-time license to use
  • All future updates
  • All premium templates / plugins.

 

Order asdocx