I'm using Stata 17 table command with fvpercent and would like to add the total frequency. I can get the total on the same line as the frequencies with a recode command but can't figure out how to combine the duplicated variable label into one.
Any ideas on how to fix this? Or am I missing an obvious alternative?
Any ideas on how to fix this? Or am I missing an obvious alternative?
Code:
collect clear . table () (var) , stat(fvfrequency rate_star) stat(fvpercent rate_star) stat(count rate_star) -------------------------------------------------------------------------------------------------------------------- | Overall hospital rating - star rating Overall hospital rating - star rating | 1 2 3 4 5 ----------------------------+--------------------------------------------------------------------------------------- Factor variable frequency | 104 409 1,342 802 86 Factor variable percent | 3.79 14.91 48.92 29.24 3.14 Number of nonmissing values | 2,743 -------------------------------------------------------------------------------------------------------------------- . collect recode result fvfrequency=Freq count=Freq (6 items recoded in collection Table) . collect style column, dups(center) . collect layout (result[Freq fvfrequency fvpercent]) (var) Collection: Table Rows: result[Freq fvfrequency fvpercent] Columns: var Table 1: 2 x 6 ---------------------------------------------------------------------------------------------------------------- | Overall hospital rating - star rating Overall hospital rating - star rating | 1 2 3 4 5 ------------------------+--------------------------------------------------------------------------------------- Freq | 104 409 1342 802 86 2743 Factor variable percent | 3.79 14.91 48.92 29.24 3.14 ---------------------------------------------------------------------------------------------------------------- .