Announcement

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

  • Export tabm to excel

    Hi all,

    I am using the tabm command (which may be a user generated one). I am trying to identify a way to export it to excel, but can't seem to figure it out! Any one have any idea? Would love to also keep all the labels visible.

    Any help would be much appreciated!

    Code:
        tabm q143?, transpose col

  • #2
    tabm (from tab_chi on SSC; no need for speculation, as search will you tell this) is just a wrapper for tabulate. Also, it has a replace option.

    What do you understand by export to excel, meaning no doubt MS Excel? The table is just a table that can be copied and pasted. The underlying data can be exported after a replace.

    Comment


    • #3
      I'm afraid I'm struggling to copy paste it to MS Excel. I can't get the delimiters right (screen shots below)

      I see the replace, am meddling with it now, its in long form with just the 2 variables rather than the desired 7 that I would like. I cannot reshape because they are unique observations.

      Not sure what to do!

      Thanks for your message

      Click image for larger version

Name:	Screenshot 2020-01-16 at 18.37.14.png
Views:	1
Size:	54.2 KB
ID:	1532288


      to:
      Click image for larger version

Name:	Screenshot 2020-01-16 at 18.37.26.png
Views:	1
Size:	373.4 KB
ID:	1532289

      Comment


      • #4
        The menu has various Table Copy Options under Edit, at least under MS Windows. I can't say that I have used them much or remember what i did use. I don't often want to copy anything much to spreadsheets myself. But plenty of others may be able to give much better advice.

        Comment


        • #5
          Thanks Nick, yeah an export would be a more replicable option. Thank you for you help!

          Comment


          • #6
            How did you copy the table from the Stata result window? If you mark the table, then right click and select "Copy table" and then paste the table into Excel, it should work. At least it does in my configuration.
            The table will not look like exactly like in the Stata result window, because the line dividers are missing, but overall the table will have all values and labels.

            Making this process reproducible is a bit tricky due to the way how tabulate (as the command behind -tabm-) export its resulting table as a matrix. While you can export the frequencies displayed, you cannot export the calculated totals or the labels used as row and column names. The row and column names themselves can be exported to separate matrices, but they will reflect only their numerical value and not their displayed names. In your case the column names would be something like "1 2 3 4 ...".

            Comment


            • #7
              This question has arisen again elsewhere. #6 is correct in what it says except for overlooking the point made in #2 that tabm has a replace option allowing a two-step (or rather four-step)

              Code:
              preserve
              
              tabm, replace
              
              * export to Excel
              
              restore
              and while no user is likely to find that ideal, there is another alternative which is to clone
              tabm under another name and embedded your own preferred export code.

              Comment

              Working...
              X