Announcement

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

  • How to erase multiple graphs from file?

    Hello


    I am generating several charts but would like to delete after graph combine. I have tried the following:

    HTML Code:
    foreach v in 0 1 8 {
    foreach x in CCL17 CXCL10 CXCL11 CCL18 {
    profileplot RCCL220_`x'0 RCCL221_`x'1 RCCL228_`x'8 if nmissccl22==0 , saving(CCL22`x'.gph)
    }
    }
    
    fs *.gph
    graph combine `r(files)'
    
    local list : dir .  files "*.gph"
    foreach f of local list {
        erase "`f'"
    }

    Local list does not list my graphs and the loop does not result in erased charts. I would be very grateful for any help on this.

    Many thanks!



  • #2
    Instead of option saving() use option name(), then the graph will be saved to Stata's memory, rather then your disk.
    You can then graph drop it or clear all.

    Comment


    • #3
      Thank you. The issue with that was that I couldn't use
      HTML Code:
      graph combine _all
      I didn't want to specify each graph name for graph combine.

      Comment


      • #4
        And you don't have to!

        Code:
        clear all
        sysuse auto
        
        twoway scatter price weight, name(g1) mc(red)
        twoway line    price length, name(g2) lc(green)
        
        quietly graph dir
        graph combine `r(list)'

        Comment


        • #5
          Perfect! Thanks so much.

          Comment

          Working...
          X