Announcement

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

  • graph could not be opened'

    I'm trying to generate and save a graph using syntax that has worked before:

    Code:
    marginsplot, title (" ") plot1opts(lwidth(thick)) plot2opts(lwidth(thick)) xtitle("Party") xsc(titlegap(4)) ///
    legend(on) ytitle("Fear") ylabel(-2(1)2) scheme(s1mono) graphregion(margin(1 10 1 1)) saving(graph1)
    Now when I run it I get the error "file graph1.gph could not be opened" which doesn't make sense to me because I'm not asking for any graph to be opened. I'm asking for a graph to be saved. The graph itself generates fine so I know that everything before "saving" is OK. This seems like a bug. Can anyone help or explain why Stata is trying to open a graph?

  • #2
    I would check where you're working.

    Code:
    pwd
    will likely tell you that you have wandered into a place where you don't have write permission. . I doubt that there is any other kind of bug, because otherwise why did the code work previously?

    Comment


    • #3
      Thanks. That worked. Would it be possible to change this message so that it does say a file couldn't be opened, but instead says it couldn't be saved?

      Comment


      • #4
        Also, is it possible to set a working directory for just a single session that resets when the session is closed?

        Comment


        • #5
          I'm sympathetic on the wording of the error message, it's fairly nerdy as it now stands. It relies on the reader understanding that programs "open" files both to read them and to write them - "open" is not a synonym for read. A clearer message would be "file graph1.gph could not be opened for writing" to hint to the unlucky user that the problem is likely to be a problem like yours.

          I know of no way to change the working directory and have it return to its previous value when the program exits.

          Comment


          • #6
            The current directory is stored in c(pwd) so you could copy that to a local for later use. So I can go


            Code:
            . local here "`c(pwd)'"
            
            . di "`here'"
            where I suppressed the result

            Comment

            Working...
            X