Stata 15 help for filename


[U] 11.6 Filenaming conventions


Some commands require that you specify a filename. Filenames are specified in the way natural for your operating system:

Windows Unix Mac ------------------------------------------------------------------------ mydata mydata mydata mydata.dta mydata.dta mydata.dta c:mydata.dta ~friend/mydata.dta ~friend/mydata.dta

"my data" "my data" "my data" "my data.dta" "my data.dta" "my data.dta"

myproj\mydata myproj/mydata myproj/mydata "my project\my data" "my project/my data" "my project/my data"

C:\analysis\data\mydata ~/analysis/data/mydata ~/analysis/data/mydata "C:\my project\my data" "~/my project/my data" "~/my project/my data"

..\data\mydata ../data/mydata ../data/mydata "..\my project\my data" "../my project/my data" "../my project/my data"

In most cases, where filename is a file that you are loading, filename may also be a URL. For instance, we might specify use

Usually (the exceptions being copy, dir, ls, erase, rm, and type), Stata automatically provides a file extension if you do not supply one. For instance, if you type use mydata, Stata assumes that you mean use mydata.dta because .dta is the file extension Stata normally uses for data files.

Stata provides 22 default file extensions.

You do not have to name your data files with the dta extension -- if you type an explicit file extension, it will override the default. For instance, if your dataset was stored as myfile.dat, you could type use myfile.dat. If your dataset was stored as simply myfile with no file extension, you could type the period at the end of the filename to indicate that you are explicitly specifying the null extension. You would type use myfile. to use this dataset.

All operating systems allow blanks in filenames, and so does Stata. However, if the filename includes a blank, you must enclose the filename in double quotes. Typing

. save "my data"

would create the file my data.dta. Typing

. save my data

would be an error.

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index