Announcement

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

  • Stata will not let me exit

    Hello all. I have run into what would seem to be a simple problem, but I cannot find the solution anywhere yet. I was attempting to solve an earlier issue (irrelevant to this post) and I copy-pasted this code from another post on here:

    ` program redo
    syntax [story_inst_control_4]
    local antvar = wordcount("`story_inst_control_4'")
    noisily display "antvar: `antvar'"`

    Unfortunately, Stata now simply will not let me quit. If i press the x in the upper right hand corner of the window, it asks me to save, and then stays open. If I code, "exit" or "exit, clear" it stays open, and merely logs the command in the display window above.

    What have I done, and how can I dig myself out of this hole?

  • #2
    Note first of all that you have posted your question in the Mata forum of StataList, which is for questions that involve Stata's Mata language. There is no harm done, but posting in the Mata forum can reduce the attention received by a question that doesn't involve Mata.

    Anyway, I see that the code you have posted starts the definition of a Stata program with the "program" statement, but nowhere is there an "end" statement. Stata therefore believes you are still in the middle of defining a program, and apparently does not allow you to quit in the middle of doing that. Look at some examples of Stata programs in the documentation and you'll see how to use the "end" statement.

    Another possible problem with your code is that it begins with a stray character, namely what some people call the "backtick:" `
    You'll want to remove that stray character, as it could cause difficulties, though likely it's irrelevant to your current problem.

    Comment


    • #3
      Thank you Mike! I used your 'end' code, but sadly to no avail.

      This is what appears on my end:

      . program redo
      1.
      . syntax [story_inst_control_4]
      2.
      . local antvar = wordcount("`story_inst_control_4'")
      3.
      . noisily display "antvar: `antvar'"
      4.
      .
      .
      . local number : word count `varlist'
      5.
      . display in gr "Number of variables = `number'"
      6. gr
      7. local n : word count "story_inst_control_4"
      8. clear
      9. do "C:\Users\clair\AppData\Local\Temp\STD1220_000000. tmp"
      10. clear all
      11. results
      12. exit
      13. exit, clear
      14. exit, clear
      15. save "C:\Users\clair\Downloads\bloop_delete.dta"
      16. exit
      17. exit, clear
      18. exit, clear
      19. exit, clear
      20. exit, clear
      21. exit, clear
      22. exit, clear
      23. exit, clear
      24. end

      .

      Comment


      • #4
        In any case, I apologize for posting here, should I delete my post here and add it on the General forum?

        Comment


        • #5
          It's impossible for me to tell exactly what all you have done in your code. It looks like you have been typing in this program at the command line, which I suppose can be done, but which is not at all a good practice. It looks like you are confused by the overall process of defining and running a program within Stata, and trying to explain that in this online context is likely not to be useful. Reading the PDF manual entry under -help program-, with a focus on the examples might help. Better yet would be to talk one to one with a human being who can explain the relevant concepts, but I understand that's likely not possible for you.

          Anyway: Once you have typed the "end" code, as above, Stata should be out of the "define a program" mode, and you should be able to exit Stata via the File-Exit menu choice, or by typing "exit" at the command line. Note that your request to "exit, clear" in the code you show is inside the program you are defining, and has no effect as typed above. Statements inside a defined program only take effect when the program is run. You have not run the program, you have only defined it. Anyway, if you still can't exit Stata after entering the "end" statement, I don't know what to advise, as it's hard to tell what's going on. If you're still stuck, I would suggest you just use the "terminate/kill a process" facility of your operating system (Windows/Mac/Unix) to stop Stata and start again. You will lose any changes to unsaved files, of course.

          I don't think it's worth deleting and moving your posting now, but you'll want to use the Stata rather than the Mata forum in the future.

          Comment


          • #6
            Thanks Mike, you are exactly right. I am very confused by the process or defining and running a program, I got into the habit of copy-pasting useful code for an intended command from my time in R - not a good practice!

            For now, I can still open up a new Stata window, so until a solution comes along I'll just keep the failed one minimized on my desktop.

            Comment


            • #7
              so until a solution comes along I'll just keep the failed one minimized on my desktop
              Petel Stvyrnksy , Mike has given you a solution. After typing end, closing the window will work. But you've typed it the very last, and apparently didn't try to exit Stata afterwards. Best, Sergiy

              Comment


              • #8
                If you type "end " it should work

                Comment

                Working...
                X