Stata for Mac PDF fixed in Stata 11.2

April 11, 2011 at 4:29 pm 3 comments

| Gabriel |

About a year ago, I got frustrated with Stata’s “graph export foo.pdf” command, which at the time gave hideous output. Apparently the problem was that Stata used the same code to write to disk as to write to screen. As a work-around, I wrote graphexportpdf.ado, which is basically a wrapper to pipe Stata-generated eps files through Ghostscript.

I am happy to report that the revision notes for Stata 11.2 include this line, from the section about Stata for Mac:

33.  Graphs exported as PDF files are now exported with increased resolution.

That is to say, they fixed it. I tested it and it creates beautiful output and does so very quickly. Thanks StataCorp!

I highly recommend that Mac users of Stata 11.2 and higher use the native PDF capabilities through the standard “graph export foo.pdf” syntax. Graphexportpdf.ado may still be useful for Mac users of versions 10 and earlier and to Linux users (who don’t have Quartz but usually have Ghostscript as part of a LaTeX distro).

Finally, remember that “graph export foo.pdf” is a Mac only option so if you want your code to be portable you should treat it like this:

if "`c(os)'"=="MacOSX" { 
  graph export mygraph.pdf, replace
else {
  graph export mygraph.eps, replace

Entry filed under: Uncategorized. Tags: , . Immediate field work opportunity


  • 1. Rense  |  April 12, 2011 at 12:04 am

    Windows users could also install Ghostview, and if they put ps2pdf is in the path system variable, I guess this should in principle allow graphexportpdf to work, except that you explicitly coded it to abort when the OS is Windows🙂.

  • […] recently noted that graph exporting to PDF in Stata for Mac is fixed. Turns out that this is only partially true. It works and creates beautiful output, but unlike the […]

  • 3. sv  |  February 26, 2013 at 6:15 am

    Hi, nice blog! I recently discovered that Stata can now export graphs to pdf on windows. I hope it generates the same output.

The Culture Geeks

%d bloggers like this: