Title stata.com
erase Erase a disk file
Syntax Description Remarks and examples Also see
Syntax
erase | rm
"
filename
"
Note: Double quotes must be used to enclose filename if the name contains spaces.
Description
The erase command erases files stored on disk. rm is a synonym for erase for the convenience
of Mac and Unix users.
Stata for Mac users: erase is permanent; the file is not moved to the Trash but is immediately
removed from the disk.
Stata for Windows users: erase is permanent; the file is not moved to the Recycle Bin but is
immediately removed from the disk.
Remarks and examples stata.com
The only difference between Stata’s erase (rm) command and the DOS DEL or Unix rm(1) command
is that we may not specify groups of files. Stata requires that we erase files one at a time.
Mac users may prefer to discard files by dragging them to the Trash.
Windows users may prefer to discard files by dragging them to the Recycle Bin.
Example 1
Stata provides seven operating system equivalent commands: cd, copy, dir, erase, mkdir, rmdir,
and type, or, from the Unix perspective, cd, copy, ls, rm, mkdir, rmdir, and cat. These commands
are provided for Mac users, too. Stata users can also issue any operating system command by using
Stata’s shell command, so you should never have to exit Stata to perform some housekeeping detail.
Suppose that we have the file mydata.dta stored on disk and we wish to permanently eliminate
it:
. erase mydata
file mydata not found
r(601);
. erase mydata.dta
.
Our first attempt, erase mydata, was unsuccessful. Although Stata ordinarily supplies the file
extension for you, it does not do so when you type erase. You must be explicit. Our second attempt
eliminated the file. Unix users could have typed rm mydata.dta if they preferred.
1
2 erase Erase a disk file
Also see
[D] cd Change directory
[D] copy Copy file from disk or URL
[D] dir Display filenames
[D] mkdir Create directory
[D] rmdir Remove directory
[D] shell Temporarily invoke operating system
[D] type Display contents of a file
[U] 11.6 Filenaming conventions