Announcement

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

  • Editing/Using old .do files

    Very new to Stata (15.1) here, so I apologize for the basic question in advance. How do I continue editing/using a do file that I've saved? I'm simply summarizing variables. When I attempt to edit a saved do file and summarize new variables, the do file runs all of the previous summaries again. Is there any way to create a break from my previous work and then continue to use/edit without it running all of my summarizes over and over

    The beginning of my do file looks like this:

    clear
    set more off
    use "use (file name)"

    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1920
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1921
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1922
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1923
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1924
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1925
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1926
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1927
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1928
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1929
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1930
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1931
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1932
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1933
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1934
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1935
    sum totalnum_banks1 totalbank_sus1 sus_nationalbank1 sus_statebank1 if state_code == 10 & year == 1936

    Everything works great. I save the do file. The next time I want to work in the data set. I open my saved .dta file, I import my .do file.

    clear
    set more off
    use "use (file name)"

    I want to summarize more stuff, so I create more commands. BUT when I go to run them, it runs all of the previous summary commands from my previous session as well. Is there way to limit what is run based on the session that I'm currently working in? How to create a break from my old session commands in the do file and the commands that I want run in my current session? Hopefully I'm being clear enough. Please explain how I can fix this like you would to a small child or golden retriever. HA
    Thank you in advance for your time.


  • #2
    In the do-editor, select (highlight) the old commands that you don't want to re-run. On the Edit drop-down menu, select Advanced. Then select Toggle Comment from the next level menu. This will "comment out" the old commands: they will appear with // in front of them, and the color of the text will change to a light green (assuming you are using the factory-set color scheme). When you run the do-file they will be skipped over, but they remain visible and preserve a record of what has been done previously.

    By the way, in Windows, you can skip the Edit menu process by just pressing Ctrl and / simultaneously once you have highlighted what you want to comment out. I am confident that a similar keyboard shortcut for this also exists in Mac and Unix, but I don't know what it is.

    Comment

    Working...
    X