I have generated the table (table_collect_stata_output) below using the auto dataset and would like assistance in refining the code to obtain the table (Desired Table Output (2. table_collect_desired)) where the totals are moved to the top and are renamed by the sublevel name as indicated in the desired table. (See images attached)
(See Attachements)
Code:
sysuse auto,clear split make , gen(make_1) collect layout (foreign make_11) (result#var) collect style header foreign make_11, title(hide) table (foreign make_11), statistic(mean price mpg) statistic(sd price mpg) totals(foreign make_11)

Comment