Announcement

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

  • Stata won't change content directory

    This is my first time using Stata. I've watched some videos about creating do files, changing the directory and importing data files. However, I keep getting error messages from Stata when I try to just change the directory. I've typed:

    cd C:\Users\myusername\documents

    in both a do file and the command box. Stata keeps returning "unable to change to (file location)." And then says r(170); which I'm assuming is an error code.

    I suspect my problem is that I do not have Stata downloaded onto my computer but am instead running it from my university's online software hub cloud thingy. Any ideas if that's probably the culprit, or am I making some dumb rookie mistake? And if it's the former, how do I get around it? I'm running StataSE 13 on Windows 7.

    Thanks.

  • #2
    You wrote that you are using Stata with Windows but if I understand the Stata documentation correctly, error 170 is for Unix and Mac operating systems. From [P] error:

    170. unable to chdir
    (Unix and Mac.) cd was unable to change to the directory you typed because it does not exist, it is protected, or it is not a directory.

    Comment


    • #3
      The Unix / Mac qualifier refers to -chdir-. Experimentation shows that in Windows Stata returns the same error code in the same situation:

      . cd nonexistentdir
      unable to change to nonexistentdir
      r(170);

      Comment


      • #4
        Jeph, thank you for the clarification.

        Comment


        • #5
          Teresa - You can experiment with the Stata user interface. From Stata's File menu, select "Change Working Directory" and then navigate to where you want to be. Stata will place the cd command it generates into the log.

          Or is it the case that you are running batch files rather than interactively? If that case, you have my sympathy. If nothing else, try issuing Stata's pwd command and see where it tells you that you're starting from. That might give you an idea of what you need to do to get where you want to be. You can also use dir and cd .. (which changes to the parent directory of the one you're in) to try to work your way to where you need to be.

          Edited: I had forgotten that you said you typed into the command box, so you are running interactively. The stuff in my first paragraph above is my recommendation.
          Last edited by William Lisowski; 25 Jun 2015, 15:03. Reason: Correct my oversight by adding the third paragraph.

          Comment


          • #6
            That worked, William! Thank you! It looks like because I'm accessing Stata from online, I couldn't use a normal address to the file. This pulled it up right, though.

            Comment

            Working...
            X