Is there a simple way to export the "underlying" data of a Stata graph in order to reproduce that graph in MS Excel? Imagine you create a ROC curve using roctab y yhat, graph and you want to reproduce that graph in Excel.
-
1That's awful hard for me to imagine wanting to do that, but one way to try would be to learn about sersets. Alternatively, try editing the .gph file. My gut is that doing the calculations directly would usually be easier.Nick Cox– Nick Cox2013-11-21 16:36:06 +00:00Commented Nov 21, 2013 at 16:36
-
Thanks Nick. I thought that Stata must store the data to build the graph somewhere (x,y coordinates), so there might be a way to grab these datapoints..yumba– yumba2013-11-21 16:48:48 +00:00Commented Nov 21, 2013 at 16:48
-
You were right. A .gph file is, naturally, not a graph, but a set of instructions on how to draw a graph. A serset is another take. [NB: not "STATA"!]Nick Cox– Nick Cox2013-11-21 18:19:30 +00:00Commented Nov 21, 2013 at 18:19
2 Answers
I assume that you do not have access to the actual raw data that was used to compile the .gph in the first place, and somehow want to back engineer the .gph file... then, eek, good luck!
If you do however have the access to the data originally used then with new command available in Stata 13, You can use the function putexcel command
A more detailed description of the putexcel command can be found here stata press releasse on exporting tables to excel
Comments
The data in the .gph file are stored in the serset format between the and tags. There's no utility I know of that will parse the serset information, but it is very similar to Stata's dta file (v115 and below). I wrote up the basic file format information here. The Python library pandas has code for reading/writing dta files so with those you could probably create your own serset reader/writer.