generated from opensafely/research-template
/
101_baseline_characteristics_allpts.do
60 lines (49 loc) · 1.79 KB
/
101_baseline_characteristics_allpts.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
version 16
/*==============================================================================
DO FILE NAME: baseline tables all pts
PROJECT: EIA OpenSAFELY project
DATE: 07/03/2022
AUTHOR: J Galloway / M Russell
adapted from C Rentsch
DESCRIPTION OF FILE: baseline tables
DATASETS USED: main data file
DATASETS CREATED: tables
OTHER OUTPUT: logfiles, printed to folder $Logdir
USER-INSTALLED ADO:
(place .ado file(s) in analysis folder)
==============================================================================*/
**Set filepaths
global projectdir `c(pwd)'
di "$projectdir"
capture mkdir "$projectdir/output/tables"
global logdir "$projectdir/logs"
di "$logdir"
**Open a log file
cap log close
log using "$logdir/descriptive_tables_allpts.log", replace
**Set Ado file path
adopath + "$projectdir/analysis/extra_ados"
**Use cleaned data from previous step
use "$projectdir/output/data/file_eia_allpts.dta", clear
/*Tables=====================================================================================*/
tabstat age, stats (n mean sd)
*Baseline table
table1_mc, onecol nospacelowpercent iqrmiddle(",") ///
vars(agegroup cat %5.1f \ ///
male bin %5.1f \ ///
ethnicity cat %5.1f \ ///
imd cat %5.1f \ ///
bmicat cat %5.1f \ ///
smoke cat %5.1f \ ///
hypertension bin %5.1f \ ///
diabcatm cat %5.1f \ ///
chronic_cardiac_disease bin %5.1f \ ///
stroke bin %5.1f \ ///
cancer bin %5.1f \ ///
chronic_resp_disease bin %5.1f \ ///
chronic_liver_disease bin %5.1f \ ///
ckd cat %5.1f \ ///
) saving("$projectdir/output/tables/baseline_allpts.xls", replace)
import excel "$projectdir/output/tables/baseline_allpts.xls", clear
outsheet * using "$projectdir/output/tables/baseline_allpts.csv" , comma nonames replace
log close