Announcement

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

  • Stata run do-file without error message but nothing happened

    Hello,

    I run into a problem with Stata. I am working on a do-File for hours, everything was working fine. Suddenly, with our changing any code, Stata stopped drawing the same graph it draws 10 times before. There isn't any error message or something. If I new start the program, it works for one time. Trying to repeat the same code is not working. I then tried to add some error manually (e.g. change varname to one that doesn't exist) and noticed that there aren't even error messages. Stata runs the do-file and display 'end of do-file' after it.

    Here is some example code:

    colorpalette plasma, n(20) nograph reverse
    local colors `r(p)'

    spmap age_mean using nuts3_shp, ///
    id(_ID) cln(10) fcolor("`colors'") ///
    ocolor(gs6 ..) osize(0.03 ..) ///
    ndfcolor(gs14) ndocolor(gs6 ..) ndsize(0.03 ..) ndlabel("Keine Daten") ///
    polygon(data("nuts1_shp") ocolor(black) osize(0.08) legenda(on) legl("NUTS3")) ///
    legend(pos(11) size(1.5) symx(2.5) symy(1.5)) legtitle("Age") legstyle(2) ///


    I tried to search for help on the internet but couldn't find anything.

    I would appreciate any kind of help!

    Thanks in advance
    KR

  • #2
    Normally a command ends at the end of a line. That way Stata knows that the first word in a line is the command and whatever comes after are variables, conditions, options, etc. and at the end of the line it is done, and can look at the next line for the next command. You can override that default using the /// comment. It means Stata can you please ignore everything that comes after me, including the end of line. So if you want to have a command over multiple lines, and that is a good idea for long commands like the spmap command you showed, then you can end each line except the last one with the /// comment. If you also include the /// command on the last line, then the command does not end on that line. If the next line is just an empty line, then it will work if you run the entire .do file. However if you just select those lines and try to run it, then it won't: it will see a partial command as it does not see an end of line character and is waiting for you to finish it.

    Long story short, just remove the /// comment on the last line of the spmap command.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Dear Maarten,

      Thank you so much! Sometimes it can be so easy.

      Grüße nach Konstanz

      Comment

      Working...
      X