Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help needed in exporting output from the groups command

    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.
    Last edited by Kartik Trivedi; 22 Apr 2019, 10:32. Reason: Added tags for easy search.

  • #2
    The output of help groups suggests the saving() option will save the results as a Stata dataset. From that, you can use the usual techniques (e.g. export excel or export delimited) to create Excel or CSV files from the saved dataset.

    Comment


    • #3
      William, thanks for bringing saving() to my attention it worked as it is supposed.

      Comment


      • #4
        asdoc can also export the output to MS word. For quick start to asdoc, this half-page introduction can be handy.
        Code:
        ssc install asdoc
        sysuse auto
        asdoc groups mpg, select(5) order(h) replace
        Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	14.6 KB
ID:	1494498

        Last edited by Attaullah Shah; 22 Apr 2019, 12:10.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment

        Working...
        X