Announcement

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

  • Breaking Execution of Stata

    Dear All,

    While running a dofile, Stata gives me the break error even though I'm not stopping the execution. The code I'm using is the following loop


    local variables unemployment population gpd_growth ln_gpd_growth wages lagged_wages

    foreach var of local variables {
    local vlabel: variable label `var'
    graph bar `var', over(label_region, label(angle(45)) sort(`var') reverse) ytitle("% `vlabel'") ///
    graphregion(color(white) ilcolor(black)) plotregion(lcolor(black))
    }

    Thanks a lot for your help!


  • #2
    The second line seems to have incorrect syntax. when your'e defining a local macro. what does that : stand for?

    In general what I do when I need to debug such issues is to go from top to bottom - commenting out (or deleting) rows starting from the second one to see where the machinery breaks.

    Comment


    • #3
      Ariel: That syntax looks fine to me. see http://www.stata.com/help.cgi?extended_fcn

      I am puzzled at a break here too.

      Comment


      • #4
        Always nice to learn something new

        I tried replicating this break on a sample data, and wasn't able too as well:

        Code:
        . sysuse auto, clear
        (1978 Automobile Data)
        
        . local variables mpg price weight
        
        . 
        . 
        . foreach var of local variables {
          2.         local vlabel: variable label `var'
          3.         graph bar `var', over(foreign, label(angle(45)) sort(`var') reverse) ytitle("% `vlabel'") ///
        >         graphregion(color(white) ilcolor(black)) plotregion(lcolor(black)) name(`var')
          4. }
        
        . 
        end of do-file
        you should probably post the output and/or provide us with some sample data that the error occurs in

        Comment


        • #5
          It seems to be an issue with the macro expansion:

          Code:
          sysuse auto.dta, clear
          loc variables mpg price weight
          foreach var of loc variables {
              loc vlabel `: variable label `var''
              gr bar `var', over(foreign, label(angle(45)) sort(`var') reverse) ///  
              ytitle(`"% `vlabel'"') graphr(color(white) ilcolor(black)) ///  
              plotr(lcolor(black)) name(`var')
          }
          On a tangental note, if Joshua Smith uses the same aesthetic commands repeatedly, it might be good to consider using brewscheme to generate a customized scheme file. This would at least help to remove additional points in the code where things could break down (e.g., could immediately rule out any graph/plot region subcommands since the scheme file would take care of those settings).
          Last edited by wbuchanan; 01 May 2016, 06:46.

          Comment

          Working...
          X