Announcement

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

  • Executing do file from top

    Hi everybody,

    Stata 12.1 offers the option of executing a do file from the current cursor position in the do editor to the bottom of the do file (<CTRL>-<SHIFT>-<D>). I have never needed this command. However, every time I work with the do editor I miss an option to execute a do file from the top to the position of my cursor. Instead I have to put some nonsense text into the do file that causes an error in order to get Stata to stop at my current cursor position when I run the do file.

    Am I overlooking something? Is this function implemented somewhere? And what would I need to option to execute from my cursor to the bottom for, when I practically never can use it because then all the definitions and steps earlier in the do file which are needed for what is farther down to run have not yet been executed.

    Anyway, I would be very grateful if somebody could point me to a more elegant solution than having to insert "circuit breakers" into the do file to make it stop where I need it to.

    Best regards,
    Stefan.

  • #2
    You can position your cursor just at the start of the line immediately after the last line you want to execute, then (on a Windows machine) press CTRL+SHIFT+HOME (I'm guessing there's a Mac or Unix equivalent to this, but I don't really know). That will highlight everything from the top of the file down to your cursor. Then click on the "do" icon at the right end of the toolbar and it will execute all, and only, the highlighted code.

    Comment


    • #3
      As per the old query in this thread, does the new improved do file editor Stata 16 include a "run from top to current line" option? It would be a fantastic option to not have to highlight, run, etc.

      Originally posted by Stefan Palan View Post
      Hi everybody,

      Stata 12.1 offers the option of executing a do file from the current cursor position in the do editor to the bottom of the do file (<CTRL>-<SHIFT>-<D>). I have never needed this command. However, every time I work with the do editor I miss an option to execute a do file from the top to the position of my cursor. Instead I have to put some nonsense text into the do file that causes an error in order to get Stata to stop at my current cursor position when I run the do file.

      Am I overlooking something? Is this function implemented somewhere? And what would I need to option to execute from my cursor to the bottom for, when I practically never can use it because then all the definitions and steps earlier in the do file which are needed for what is farther down to run have not yet been executed.

      Anyway, I would be very grateful if somebody could point me to a more elegant solution than having to insert "circuit breakers" into the do file to make it stop where I need it to.

      Best regards,
      Stefan.
      __________________________________________________ __
      Assistant Professor, Department of Biostatistics and Epidemiology
      School of Public Health and Health Sciences
      University of Massachusetts- Amherst

      Comment


      • #4
        While I see that this functionality could come in handy, I really do not find it too cumbersome to simply type the letter e (abbreviation for exit) in an extra line so the do-file will stop at that position.

        Best
        Daniel
        Last edited by daniel klein; 02 Sep 2019, 08:22.

        Comment


        • #5
          Thanks- I've used the "short circuit" method too. Just so very inelegant. (Stata 17?)

          All in all a minor quibble; the new syntax completion is fantastic!
          __________________________________________________ __
          Assistant Professor, Department of Biostatistics and Epidemiology
          School of Public Health and Health Sciences
          University of Massachusetts- Amherst

          Comment

          Working...
          X