title: Pie charts in Stata
body: <p>I'm using the code below to draw some graphs and combine them. When I execute the entire file I get the error:</p>
  
  <blockquote>
    <p>"Invalid Syntax r(198)". </p>
  </blockquote>
  
  <p>And the code stops at the code segment below.  However, when I run the code segment separately the program works without a flaw.  Can you please help me understand what's causing this issue? </p>
  
  <pre><code>*pie chart 
  foreach i in "SPA" "EPD"{
      graph pie  billed_amount if type== "`i'", over(service_id) saving(gg`i',replace) 
      local gg `gg' "gg`i'"
  }
  local gg: subinstr local gg "ggSPA" `""ggSPA""'
  gr combine `gg'
  graph export "C\provider.png", as(png) replace
  graph drop _all
  </code></pre>