Announcement

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

  • How to save graphs from loop in particular folder

    How to save graphs from loop in a particular folder.


    I have my out foder:

    global MY_OUT "C:\Users\out"

    and the loop as below:




    foreach y of varlist reer cpi gdpgr {
    local graphtitle : var lab `y'
    twoway (line c tp,title("`graphtitle'") legend(off) lwidth(0.25 ) ///
    lcolor(black) lpattern(solid))(line trq tp,lwidth(0.4) lcolor(black) ///
    lpattern(solid))(line l tp,lwidth(0.25 ) ///
    lcolor(black) lpattern(longdash)) (line u tp ,lwidth(0.25 ) lcolor(black) ///
    lpattern(longdash) ///
    xlabel(-3 "t-3" -2 "t-2" -1 "t-1" 0 "t" 1 "t+1" 2 "t+2" 3 "t+3") ///
    yline(0,lwidth(0.25 ) lcolor(black) lpattern(shortdash)) saving(`y' , replace ))
    drop tp c trq l u
    local graphnames `graphnames' `y'
    }

    I was using something like
    saving($MY_OUT\`y' , replace ) but it still saves the graphs in my do folder and not in my out folder.









  • #2
    Use a forward slash in the saving() option.The use of a backslash before a local macro name is a documented no-no.

    Code:
    search backslash

    Comment


    • #3
      I still don't get how to do that. Could you help me with one example?

      Comment


      • #4
        Code:
        saving($MY_OUT/`y' , replace )

        Comment


        • #5
          thanks

          Comment

          Working...
          X