Exporting Graphs with asdocx


Exporting graphs and charts from Stata to a Word document with asdocx is as easy as adding asdocx to the beginning of any graph / chart command. So the syntax remains the same as using asdocx with any other Stata command. In the following lines, I show how we can export summary statistics and graphs to the same document. It will take just two lines of codes, with stunning output.

 

How to export graphs


In the first line of code, I shall load the auto dataset from the Stata system directory to run our example. In the next two lines, I export summary statistics and a scatter graph.

* Load the auto dataset
sysuse auto, clear

* Make and export a scatter graph
asdocx scatter mpg price

* Send summary statistics of all variables to the same document
asdocx sum

 

Please note that we just added asdocx with the scatter mpg price. This one line not only creates the scatter graph, but also exports it to the current document. We can add all available options with graph / scatter / line / twoway commands to format the graph in way we would like it. The document looks like this

 

 

Graph Height and Width


When exporting graph to a Word documents, users can now use options width() and height() to control the width and height of the graph. For a high resolution graph, the width and height values can be set as high as desired.

sysuse auto, clear
asdocx scatter rep78 price, width(2000) height(3000)

 

Community Contributed Graphs


asdocx allows exporting graphs from several community-contributed packages (available on the SSC).  Supported packages include the following:

  1. calibrationbelt
  2. coefplot
  3. dstat
  4. floatplot
  5. heatplot
  6. hexplot
  7. multidensity
  8. reldist graph
  9. riocplot
  10. tabplot
  11. vc_graph