In this video, we will guide you on how to change the directory Stata uses when executing an analysis. By the end, you’ll grasp the concept of a working directory and learn how to modify Stata’s working directory.
Your computer comprises numerous folders, perhaps tens or even hundreds. Initially, Stata is uncertain about where to search for your data. The “working directory” signifies the folder containing the data you aim for Stata to process, and it’s also the directory where Stata will save its output.
To modify Stata’s working directory, utilize the CD command. The format involves typing “CD”, followed by a space, then the path of the directory enclosed in quotation marks. For example: CD “path_of_the_directory”.
To guide Stata to the location of your stored data, you first need to get the directory address. Navigate to your desired data file. At the top of the Explorer window, you’ll find an address bar. Click on it, then right-click and select copy. This copied directory often starts with a letter, followed by a colon, a slash, and is further separated by various folder names.
Next, head over to Stata. In the command window, type in CD, followed by a space, and then paste the copied address within quotation marks. Press Enter. If done correctly, Stata will display the folder you’ve directed it to. If there’s a mistake, you’ll receive an error message.
You need to inform Stata about where to locate data and save its output files.
The directory Stata uses for these tasks is termed the “working directory”.
To alter Stata’s working directory, employ the CD command, formatted as: CD “directory_path”.