StatTransfer … who needs it?

Once more working on some standarized data to generate some standard output and graphs in * yuck * Excel. Well, we have to learn to live with the fact that some people and organizations don’t want STATA graphs and tables. So we have to export to Excel. In my case this were several tables and cross tables that were then linked to Excel Graphs. So far I did this with copy-pasting or using StatTransfer, today I found a different way …

xmlsave quickscan, doctype(excel) replace

So xmlsave is my new friend for quick export from (and for those interestested also import to) STATA to Excel. The command generates an XML file in a format that Excel reads (and writes).

4 thoughts on “StatTransfer … who needs it?

  1. Wow, that’s cool! Eventually, a .xml-file is generated which can be opened directly by Excel. There is a similar command which works well:

    outsheet using quickscan.csv, delimiter(“;”) replace

    The result is an comma-separated file which can also be opened by Excel. Is there actually a difference?

  2. With the xml, you can read/write more easily. For example, you could include worksheets in the Excel file. Too fancy for my “Quickscan” project at this time, but maybe in the future.

  3. No, you cannot use non-STATA datasets in merging operations. The way around it is to add the following lines in your do-file:

    use data.xml
    sort var /* the variable you are merging on is “var” */
    save tmp_data, replace
    merge var using tmp_data

Leave a Reply