Dear all
I am struggling to build a simple table with the table command.
There are 25 variables, named HSUS_* (ratings from Likert scales).
I want to use hosp_off as grouping var.
I need a table with means, SDs and % with a specific value of HSUS_* (HSUS_*>4), stratified by values of hosp_off. So HSUS_* vars would be listed as rows and six values in columns.
This code brings me nearly there but I do not manage to get the percentage values of HSUS_* in the same row as the other statistics.
Any help would be very appreciated.
Thank you, and happy holidays!
------------------ copy up to and including the previous line ------------------
I am struggling to build a simple table with the table command.
There are 25 variables, named HSUS_* (ratings from Likert scales).
I want to use hosp_off as grouping var.
I need a table with means, SDs and % with a specific value of HSUS_* (HSUS_*>4), stratified by values of hosp_off. So HSUS_* vars would be listed as rows and six values in columns.
This code brings me nearly there but I do not manage to get the percentage values of HSUS_* in the same row as the other statistics.
Code:
table (var) (hosp_off), statistic(mean HSUS_1 HSUS_2) statistic(sd HSUS_1 HSUS_2 ) statistic(fvpercent 5.HSUS_1 5.HSUS_2 ) collect recode result mean = column1 sd = column2 fvpercent=column3 collect layout (var) (hosp_off#result[column1 column2 column3] )
Thank you, and happy holidays!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int CASE byte hosp_off int(HSUS_1 HSUS_2 HSUS_3) 1291 1 4 5 4 1309 1 4 4 4 1478 1 4 3 3 1610 1 4 4 3 1916 1 . . . 549 1 3 4 3 903 1 4 4 3 556 1 5 3 3 1855 1 4 4 3 1132 1 . . . end
Comment