Hello,
I have a dataset with 5 different cohorts, each with their own sampling weights. The variables in this dataset are:
I wanted like to create a Table 1 (demographics table) in Stata using the Collect system, while applying the different survey weights. However, I can not find how to use svy command with table command (closest I have found is page 60 of this manual).
Normally, when using unweighted data, I make a table 1 using the below command:
However, is there a method of using the aforementioned code while applying svyset/svy for each of the 5 cohorts to obtain a similar Table 1?
With much gratitude in advance! Apologies for not including a dataset, I would be happy to repost this question with a public dataset if you can point me to such a dataset!
I have a dataset with 5 different cohorts, each with their own sampling weights. The variables in this dataset are:
Code:
outcome_variable exposure_variable // a continuous variable covariate_1 // a categorical variable covariate_2 // a categorical variable samplingweight_1992 samplingweight_1998 samplingweight_2004 samplingweight_2010 samplingweight_2016
Normally, when using unweighted data, I make a table 1 using the below command:
Code:
collect: table ///
(var) ///
(cohortyear covariate_1), ///
statistic(mean exposure_variable) ///
statistic(sd exposure_variable) ///
statistic(fvfrequency covariate_2) ///
statistic(fvpercent covariate_2) ///
nototals
collect recode result ///
fvfrequency = variable_measure ///
fvpercent = variable_spread ///
mean = variable_measure ///
sd = variable_spread
collect label levels result variable_measure "Count / Mean" variable_spread "% / (SD)"
collect layout ///
(var[exposure_variable covariate_2]) ///
(cohortyear#covariate_1#result[variable_measure variable_spread])
With much gratitude in advance! Apologies for not including a dataset, I would be happy to repost this question with a public dataset if you can point me to such a dataset!

Comment