Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reverse Command Lookup for .gph File?

    Hi Everyone,

    I'm new to Stata, so apologies for the newbie question here. I'm wondering if there's any way to reverse lookup Stata commands for a graph (saved as a .gph file). I want to share the commands so someone else can open and edit the graph file. I did copy commands when I created the graph, but they are coming up with an error message, so something must have gone wrong there. Hoping there's some way I can re-create these.

    Thanks!

  • #2
    Welcome to the Stata list. It's not clear what you mean by "there were errors", as that is not diagnostic. In the FAQ, you are asked to provide detailed code and output when asking for help. I presume your colleague is using an earlier version of Stata than the one used to create the graph in the first place. Or else, there's some other problem that we can't identify without the requested details.

    To your direct question, there's no magic bullet here, I'm afraid. You're one possible workaround would be to compile the same command (or as close as you can come) used to make the graph along with the dataset and send it to them. Then again, if they just need to visually inspect it, why not export it using any standard graphic file format, like jpg?
    Last edited by Leonardo Guizzetti; 13 Sep 2021, 21:38.

    Comment


    • #3
      Leonardo Guizzetti gives excellent advice, to which a little can be added. The .gph file clearly is a set of instructions to make a graph -- how could it be otherwise? -- so in the best circumstance looking inside is informative. But often not so. For example, a .gph file may refer to temporary variables that the command that was typed created before it produced the final graph, and only by re-executing the command can you make progress.

      If something went wrong, it's occasionally possible to fix a graph in the Graph Editor. It's much more common that the command needs to be changed.

      So, if you need to share the commands, share the commands. The .gph file has no more information for debugging, and often much less.

      Comment


      • #4
        If I am understanding your question and the Stata manual correctly, graph describe may provide a partial solution.

        It returns the graph command, dta file in memory when the graph was created, and other potentially useful items.

        I have previously suggested that Stata offer a way to save additional custom metadata in the .gph file that could subsequently retrieved as graph describe does. I hope this will be implemented one day.


        Last edited by Bert Lloyd; 14 Sep 2021, 12:50.

        Comment


        • #5
          Thanks for these replies! It's good to know I'm not just missing some obvious shortcut here. Bert, I think your request is a great one – I hope that becomes implemented in the future.

          I was hoping to be able to return to my graph to edit, but it sounds like the best thing is to just re-create it. Appreciate the input.

          Comment

          Working...
          X