Skip to content

Instantly share code, notes, and snippets.

Created April 11, 2012 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2362203 to your computer and use it in GitHub Desktop.
Save anonymous/2362203 to your computer and use it in GitHub Desktop.
* If there are three users working with the same do-file but storing their work in different directories on their local machines,
* use the following code to change to the project folder: ***
capture cd "C:/Documents and Settings/User_1/Working/Paper2/final_folder/"
capture cd "D:/Documents and Settings/User_2/final_folder/"
capture cd "Z:/Documents and Settings/User_3/Project2/final_folder/"
*** The capture command will check whether the directory on the first line exists. If it does, it will make it the current directory.
*** If the directory does not exist, Stata will check whether the second one exists, and so. The role of -- capture -- here is to
*** prevent Stata from halting when it encounters an error (i.e. a non-existing directory, in this case).
* If the only difference in the paths used by the three users is the username, then it is possible to replace the above code with:
cd "C:/Documents and Settings/`c(username)'/final_folder/"
*** Note: the `c(username)' captures the system username of the user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment