Announcement

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

  • Do file displaying error in Stata editor

    Dear all,

    All my do files that I save to my computer from the editor and Stata window (i.e. the normal crtl-s save feature) are displaying 'NUL' when I try to open them in the Stata editor. I also can't access the do files using a command from another do file. The specific error is in the image that I attached. Nothing has been changed to Stata or the way I have been using it as far as I know, and this problem has never arisen prior to today.

    I have Stata 12 and it's the MP version.

    It's really over my head what's causing this. I'd appreciate any help that you can offer to explain and assist in fixing this issue.

    Sincerely,
    WTJ
    The error displayed when opening an ordinary do file on my Stata editor

  • #2
    Wow, it's really odd, but it happened to me too a few months ago. I think the source of it was that I downloaded a corrupted pdf file, which then triggered something on my computer such that all .do files (and other tex files) I had open to face a similar problem. I never discovered a solution to it -- asked around a lot with no real answers. Maybe you have the content backed up? I am eager to see if anyone else has ideas too...

    Comment


    • #3
      Nothing surprising in this case.
      The evidence indicates that what is opened in the do-editor is a Stata data file, not a do file. Inspecting further we can conclude that the file is from Stata 12, or saved from Stata 13 with the saveold command. The file was produced by a Windows version of Stata. The file probably contains 2 variables.
      1. Don't open Stata datasets in the do-editor. It is a wrong tool for that. If opened accidentally, close right away. If you make any changes, you risk to ruin your data after saving.
      2. Read help for the save command. It doesn't save your do-script to a file, it saves your data to a file!
      3. Read the messages that Stata shows you on the screen. Most common mistake is ignoring them. When Stata closes, it will ask about every unsaved file and the data in memory. Give them correct names and extensions so that you don't get confused later.
      4. Check your files associations. Your .dta files must be associated with a use command in Stata. Your .do files must be associated with a doedit command in Stata. Stata has a "reset file associations" menu item. Use it to fix them if necessary.

      Best regards, Sergiy Radyakin

      Comment


      • #4
        Originally posted by Sergiy Radyakin View Post
        Nothing surprising in this case.
        The evidence indicates that what is opened in the do-editor is a Stata data file, not a do file. Inspecting further we can conclude that the file is from Stata 12, or saved from Stata 13 with the saveold command. The file was produced by a Windows version of Stata. The file probably contains 2 variables.

        Best regards, Sergiy Radyakin
        Dear S. Radyakin,

        Please see my attached image showing that the file I loaded was indeed a do file, and not a dta. file. With that in mind, are you aware of any situation that can cause this error with a do file?
        Attached Files

        Comment


        • #5
          Your image doesn't resolve the issue. Giving a file .do extension doesn't itself make that file one that can be edited with the do-file editor. I don't have another explanation.

          Comment


          • #6
            Try this:
            • Start Stata.
            • Open the Data Editor.
            • In the Data Editor, click on File - Open.
            • Under "Files of type", select "All Files (*.*)".
            • Select your "test" file and click "Open".
            A Stata data file with the name "test.do" will be opened in the Data Editor this way. I tested this with Stata 12.

            Comment


            • #7
              Nick Cox has already explained that file extension has no consequence on the file content. It's merely a tag, a hint, a suggestion for the operating system on what program to use to open the file. In your case that suggestion obviously is wrong.

              Friedrich Huebler has suggested how you can see that the file is a data file, by using the data editor. That should work, but only if WT Jiang hasn't yet corrupted the .dta file by edits in the do-editor.

              WT Jiang writes among other:
              normal crtl-s save feature
              I would suggest for beginners leaving the hotkeys aside, and clicking on the menus first. That is usually less prone to errors. In that case you would know what you are saving at this time: data or code.

              I have a suspicion that WT Jiang comes out of an experience with some other package, which supports a concept of a workspace, allowing to combine data and code in a single project file (say, Limdep, or something else). This is not true for Stata. If you are closing Stata, you would get messages in sequence on whether you want to save changes to your code and data (who knows in which sequence), and if you pick the same name, the last piece overwrites the earlier, but you can also end up with a file with mismatched extension and content.

              It's hard to believe the error keeps on going over and over, but if this is true:
              All my do files that I save to my computer
              than careful observations of what the user is doing can easily reveal the problem.

              Best, Sergiy Radyakin

              Comment


              • #8
                Originally posted by Friedrich Huebler View Post
                Try this:
                • Start Stata.
                • Open the Data Editor.
                • In the Data Editor, click on File - Open.
                • Under "Files of type", select "All Files (*.*)".
                • Select your "test" file and click "Open".
                A Stata data file with the name "test.do" will be opened in the Data Editor this way. I tested this with Stata 12.

                Dear F. Huebler,

                Thanks for your advice. The recommendation worked as far as I know! I opened a file with the .do extension in "all file" format, and subsequently was not only able to launch that file in the do file editor, but all others that I have been having trouble with as well. From now on, saving each file carefully in the do file format will be an issue I need to pay attention to.

                Sincerely,
                WTJ

                Comment


                • #9
                  Your answer is confusing. Was the "test.do" file a Stata data file or a do-file? My suggestion to open the file in the Data Editor would only work if you had indeed a data file.

                  Comment


                  • #10
                    Should have been a data file.
                    This used to happen to people before.

                    Sergiy

                    Comment


                    • #11
                      Dear WT Jiang, it happened the same to me two days ago, but only with one do file, the rest seem to work ok. Could you explain me what you did to solve the problem?
                      Thank you
                      Victoria

                      Comment


                      • #12
                        Victoria, to save a do-file use the File menu of the do-editor, not the main Stata menu.
                        Best, Sergiy

                        Comment


                        • #13
                          Same thing happened to one of my do file. I confirm it is NOT a .dta file with a .do extension (it opens properly in Textpad with syntax highlighting and all). Other do-files open ok.
                          The work around was to copy-paste the content into a new do-file (using Textpad).
                          Weird.

                          Comment


                          • #14
                            Well, I think I have the answer in my case. I keep my do-files and data files on an encrypted partition (I use VeraCrypt) and it seems that mounting (decrypting) the volume messes things up with Stata's ability to read the do-files (TextPad can still read them).
                            The solution will probably be to move my do-files on an unencrypted volume - it's the data that is sensitive, not the do-files.

                            Comment


                            • #15
                              The same thing happened to me this morning. One of my dofiles that I've never had any problem with suddenly will only open as a single row of NUL NUL NUL repeated over and over. Copying and pasting into another dofile doesn't seem to fix it, nor does copying and pasting it into another text editor (e.g., Notepad)

                              Comment

                              Working...
                              X