Announcement

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

  • Graph Combine only when all necessary graphs are available

    Hello,

    I'm currently combining a series of graphs (stored on disc) using a loop to create about 80 combined graphs. Is there a possibility to only create the combined graph when all (in my case: 4) graphs are available? Or is it possible to automatically insert something like a placeholder?

    Any ideas are greatly appreciated! Thanks!

  • #2
    Welcome to Statalist.

    I find it difficult to imagine exactly what your current code might be. Or rather, I can imagine several things it might be, but each thing I imagine leads to a different recommendation.

    Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

    It would be particularly helpful to copy your commands your Stata Do-file editor window and paste them into your Statalist post using CODE delimiters, as described in section 12.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Comment


    • #3
      Hello William,

      thank you for your reply. I'm working with Stata 15 and the code looks like this at the moment (simplified). I'm combining the four graphs A to D. For some IDs I don't have all four graphs. I would like to
      1) Either: Skip an ID if not all graphs are available. At the moment Stata is creating a combined version of those available.
      2) Or: Include a placeholder for those graphs which are missing.

      Code:
      levelsof ID, local(levels)
      foreach l of local levels {
      
      cap graph combine graphD_`l'.gph graphB_`l'.gph graphA_`l'.gph graphC_`l'.gph, col(4) xsize(10)
      
      graph drop _all
      }
      I hope this makes more sense
      Katja

      Comment


      • #4
        For 1, check if all four files exist and only generate the graph if they do. For 2, make a copy of the placeholder graph and give it the name of the missing file.
        Code:
        help confirm
        help ifcmd
        help copy
        The first answer on this page shows how capture confirm file can be used together with the if command.

        Comment


        • #5
          Thank you very much Friedrich! I'm already working with Stata for some years, still I've never come across the confirm comand.

          Comment

          Working...
          X