tabulate varname
command is handy in Stata, but sometimes it returns a too long result, if varname
contains too many unique values.
The third-party command, groups
, will solve the problem by showing top values only. Please use ssc install groups
to install groups
. The usage of group
is very similar to tabulate
. Here are some examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
. sysuse auto (1978 Automobile Data) . groups mpg, order(h) select(5) +-------------------------------+ | mpg Freq. Percent Cum. | |-------------------------------| | 18 9 12.16 12.16 | | 19 8 10.81 22.97 | | 14 6 8.11 31.08 | | 21 5 6.76 37.84 | | 22 5 6.76 44.59 | +-------------------------------+ . groups mpg, order(h) select(f >= 3) +-------------------------------+ | mpg Freq. Percent Cum. | |-------------------------------| | 18 9 12.16 12.16 | | 19 8 10.81 22.97 | | 14 6 8.11 31.08 | | 21 5 6.76 37.84 | | 22 5 6.76 44.59 | |-------------------------------| | 25 5 6.76 51.35 | | 16 4 5.41 56.76 | | 17 4 5.41 62.16 | | 24 4 5.41 67.57 | | 20 3 4.05 71.62 | |-------------------------------| | 23 3 4.05 75.68 | | 26 3 4.05 79.73 | | 28 3 4.05 83.78 | +-------------------------------+ |