Write png graph file from Stata to Excel
<p>I'd like to create graphs in Stata and to export the underlying graph data (not the raw data from which they were produced) to Excel, altogether with the graph file. I think I stick to the official code documentation on <code>putexcel</code> by StataCorp (<a href="http://www.stata.com/manuals14/pputexcel.pdf" rel="nofollow noreferrer">http://www.stata.com/manuals14/pputexcel.pdf</a>), but I keep getting the following error message: </p>

<pre><code>picture: expression must be enclosed in ()
</code></pre>

<p>When I enclose the relevant code line in parentheses I get the error </p>

<pre><code>unknown function picture()
</code></pre>

<p>Any advice or hint on that? See below for a ready-to-run code sample.</p>

<pre><code>sysuse auto, clear
* ------ place for some data manipulations (snip) -----------

tempfile data
save `data'

* plotting
graph bar price foreign
graph export "test.png", replace

* Export plot data (works only w/o by-option in graph command)
serset use
export excel "graphdata.xlsx", sheet("test") firstrow(variables) sheetreplace
putexcel H20 = picture(test.png) using "graphdata.xlsx", sheet("test") modify
serset clear

* re-use original data and plot next graph
use `data', clear

*...
</code></pre>