Changing the default working directory in Stata for Linux/Unix is only a matter of entering three lines of code in one file. To my surprise, this information was hard to find. So I thought I’d document the steps I took to change my default working directory/folder on CrunchBang Linux.
Before the change, the default working directory in my Linux box was
I wanted my new default directory to be called malariatrial and its path to be
Step 1: Create a new directory
I created a new directory in the directory
~/stata10 and named it malariatrial. You can call your new directory anything you want but be sure to substitute malariatrial in the steps below with your chosen directory name.
Step 2: Add a program to the program.do file
Look for the program.do file, which is a do-file that Stata executes every time we launch it. In my system, I found the program.do file as a hidden file in the home directory.
Open the program.do file with a text editor, and at the bottom of the file, add the following three lines of code:
Close the file and reboot.
You should now enter the new directory (
~/stata10/malariatrial, in my case) whenever you open Stata.
That’s it, and there is no step 3. 🙂