Of course this wouldn't work if the working directory were c:\users\bbadger\ instead. If the working directory is c:\users\bbadger\dissertation, the relative path to the same file is: users/bbadger/dissertation/data/rawdata.dtaĪ relative path starts with just the name of a folder, which is assumed to be a subfolder of the working directory. For example:Ĭ:\users\bbadger\dissertation\data\rawdata.dtaĪn absolute path in Linux or MacOS starts with a forward slash, representing the root directory, and puts a forward slash between each folder:
STAT TRANSFER USE FIRST ROW AS NAMES WINDOWS
In Windows an absolute path typically starts with a drive letter followed by a colon, and then puts a backslash between each folder. An absolute path starts at the root and lists all the folders and subfolders needed to get from there to the location of the file or folder. In Windows, if you start Stata by double-clicking on a Stata file, the working directory will be set to the location of that file, making this easiest way to get to work in Stata.Ī path specifies the location of a file or folder. Where path should be replaced by the path to the folder you want to make the new working directory. You can change the working directory with the cd (change directory) command: If you save a file without specifying a location, Stata will put it in the working directory. If you try to load a file without specifying its location, Stata will look for it in the working directory. Think of it as your current location in the file system hierarchy. Stata keeps track of a working directory, which is shown in the lower left corner of the Stata window. In Linux or on a Mac, it's just called the root directory. In Windows the root of the tree is usually a drive letter, like C: or U. But research projects with their many interdependent files require that you pay attention to where the files are located and how they're organized.Ī file system consists of folders (also known as directories) that can contain files and/or other folders, all organized in a hierarchy or "tree." A folder that is contained in another folder is also called a subfolder. You may never have given file systems much thought-most applications these days try to keep you from having to. Most data sets you'll work with will be files that are stored in a file system.
STAT TRANSFER USE FIRST ROW AS NAMES HOW TO
In this section we'll discuss how to get data sets into Stata. This is part two of Data Wrangling in Stata.