I am trying to generate frequencies for a certain variable and the groups command from the package 'groups' (ssc install groups) works great for me.
Reason I am using groups instead of tabs is to limit the output to only top 10 results.

Question: Is there a way to export the output to excel or csv. For my data I need to run similar statistics for different variable combinations and I am using loop for that.

For example desired format of the output is -
Code:
. groups mpg, select(5) order(h)

  +-------------------------------+
  | mpg   Freq.   Percent     %<= |
  |-------------------------------|
  |  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 |
  +-------------------------------+
(ref: https://www.statalist.org/forums/for...updated-on-ssc)

Alternatively, is there a way to limit the number of results to only top N results by using the 'tab' command? If so then I might be able to use tabout to accomplish what I want.