Hi All,
I would like to have a table that shows two levels and frequencies. I have bounced back and forth between dtable and table function. Any help would be greatly appreciated! Here is sample data from nhanes2.
Problem: I need to group the "race" variable with a higher level of "Rural." Dtable does not seem to allow to multiple "by" statements, so I switched to Table
Question: how can I show the frequency under the "race" labels as in the dtable example above? If not possible, just displaying the N for each racial group somewhere.
Question: how to remove the top "rural" header?
Not necessary but would be nice: Is there a way to add a horizontal line between "urban" "rural" and "total"
Thank you!
I would like to have a table that shows two levels and frequencies. I have bounced back and forth between dtable and table function. Any help would be greatly appreciated! Here is sample data from nhanes2.
Code:
dtable i.agegrp, by (race) column( by(hide) ) /// sformat("(N=%s)" frequency) /// sample(, statistic(frequency) place(seplabels) ) /// nformat(%9.0f)
Problem: I need to group the "race" variable with a higher level of "Rural." Dtable does not seem to allow to multiple "by" statements, so I switched to Table
Code:
table (agegrp) (rural race), /// statistic(percent, across(agegrp)) /// nformat(%9.0f percent) sformat(`"%s%%"' percent)
Question: how can I show the frequency under the "race" labels as in the dtable example above? If not possible, just displaying the N for each racial group somewhere.
Question: how to remove the top "rural" header?
Not necessary but would be nice: Is there a way to add a horizontal line between "urban" "rural" and "total"
Thank you!
Comment