Announcement

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

  • Save as matrix / export results of table command (when using weights and fvproportion)

    Dear All:

    I create with table a two-way-table with proportions within each factor-variable level. This works well.

    Now I would like to continue working with resulting table, either as a matrix or dataset (also happy to export as CSV to Excel). But it eludes my how to do it.
    My search revealed alternatives to table, e.g. xtable or tabulate. But with those I am not able to create that table as I would like to have it (usuall weights or proporations are an issue).

    In any case here is a workable example:

    webuse total, clear
    table heartatk (sex) [pw=swgt], stat(fvproportion race)

    How do I save/export the results of this command to continue working with it?

    Thank!
    Stefan


  • #2
    There are examples of how to export to destinations such as Word, Excel, etc in the documentation for collect (see -help collect- and especially -help collect export-). However, this is a new command and many here are not very familiar with it so help may be slow.

    One of my wishes is that the results of -table- and -collect- be accessible as a dataset, but this is not (yet) possible. If you need to do this, then you have to export as an Excel file then re-import the results, or else find a different way to construct your table "by hand".

    Comment


    • #3
      I created a command that exports stored results in --collect-- to a Stata frame. Be aware you need to have Python set up within Stata to use it.

      https://github.com/daniel-alves-fern...llect-to-frame

      Code:
      webuse total, clear
      table heartatk (sex) [pw=swgt], stat(fvproportion race)  
      collect_to_frame mytable

      Comment


      • #4
        Thanks for the pointer to "collect"! I wasn't aware of this one.

        Its a bit cumbersome, but it gets the job done!

        Cheers!
        Stefan

        Comment

        Working...
        X