Announcement

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

  • Code doesn't execute some commands

    Hey,

    when I run a long do file, it kind of "skips" part of the commands. Stata writes all lines of the code as if they were all executed, but some of them aren't really (for example "gen", "preserve" etc.).

    Before I'll elaborate more of the exact commands and code I ran, does anyone have a general idea what can cause that kind of problem? Note that when I ran the same code line by line it all goes well.

    Thanks a lot in advance,
    Ben

  • #2
    Probably because your code does something other than you expected.
    Best guess, as you indicate it has preserve in there: anything after preserve will be executed, but changes to the dataset are undone when getting to restore.
    If you explain what you wanted Stata to do, and what your actual code was, will make this 100% easier to diagnose.
    The idea that Stata would skip lines though, that is not very likely going to be the issue here.

    Comment


    • #3
      To add to Jorrit's comments, you'll help us answer your question by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. You can cut down your posting to the minimum needed to generate the issue.

      Does Stata echo back the kind of return codes it does when lines are executed? Generate should be followed by return code that would include a statement of number of missing generated if you do create missing observations.
      set obs 100
      g a=1
      r; t=0.00 10:21:22

      In addition to the preserve possibility, another possibility is that you've got a comment section that blocks out the code that is not running. Running line by line would then work, but not the full program. But it could also be the preserve (but then you'd see the proper return codes indicating the lines ran but not have the changes later).

      Comment

      Working...
      X