Hi everyone,
I am trying to create a summary statistics table by gender for 2 different variables (in rows) where I would like to have the following columns - mean, standard deviation, number of non-missing values, number of missing values and percentage of missing values. The first three are easy using the statistic but for the last two I have created a new variable using the missing command.
This is what I run:
This is what it looks:

The problem is that I would like Factor-variable frequency to be in one column (540 below 2538) and Factor-variable percent to be in one column. How can I do that?
Thank you in advance!!!
I am trying to create a summary statistics table by gender for 2 different variables (in rows) where I would like to have the following columns - mean, standard deviation, number of non-missing values, number of missing values and percentage of missing values. The first three are easy using the statistic but for the last two I have created a new variable using the missing command.
This is what I run:
Code:
webuse nhanes2, clear
gen lead_missing = missing(lead)
gen zinc_missing = missing(zinc)
collect clear
table (var) (sex), ///
statistic(mean lead ) ///
statistic(sd lead) ///
statistic(count lead) ///
statistic(fvfrequency lead_missing) ///
statistic(fvpercent lead_missing) ///
nototals ///
nformat(%6.2f mean) ///
nformat(%6.2f sd) ///
sformat("%s%%" fvpercent)
table (var) (sex), ///
statistic(mean zinc ) ///
statistic(sd zinc) ///
statistic(count zinc) ///
statistic(fvfrequency zinc_missing) ///
statistic(fvpercent zinc_missing) ///
nototals ///
nformat(%6.2f mean) ///
nformat(%6.2f sd) ///
sformat("%s%%" fvpercent) append
collect preview
collect layout (cmdset) (sex[1]#result sex[1]#result#var[ 1.lead_missing 1.zinc_missing] sex[0]#result sex[0]#result#var[ 1.lead_missing 1.zinc_missing])
The problem is that I would like Factor-variable frequency to be in one column (540 below 2538) and Factor-variable percent to be in one column. How can I do that?
Thank you in advance!!!

Comment