Differences between revisions 1 and 2
Revision 1 as of 2020-01-15 17:21:00
Size: 1522
Comment:
Revision 2 as of 2020-02-27 17:12:30
Size: 1545
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:

<<TableOfContents>>

Stata File I/O

Stata is capable of handling most file formats, including proprietary ones.


Excel

To import from an Excel spreadsheet:

import excel using "path/to/file", sheet("Sheet1") firstrow

To export into an Excel spreadsheet:

export excel using "path/to/file", sheet("Sheet1") firstrow(variables) replace

For exporting reports into Excel, see documentation on putexcel.


CSV

To import from a CSV file:

import delimited using "path/to/file", delimiters(",") varnames(1)

Often, the stringcols(_all) option is necessary.

If there are no column labels, use varnames(nonames).

To export into a CSV file:

export delimited using "path/to/file", delimiters(",")

To suppress column labels, use novarnames.


Tab-Delimited

To import from a tab-delimited file:

import delimited using "path/to/file", delimiters("\t") varnames(1)

Often, the stringcols(_all) option is necessary.

If there are no column labels, use varnames(nonames).

To export into a tab-delimited file:

export delimited using "path/to/file", delimiters("\t")

To suppress column labels, use novarnames.


Old Stata Versions

Stata does not support handling data from all versions of Stata. To go beyond the supported range, use saveold.

saveold "path/to/file", version(11)


CategoryRicottone

Stata/FileIO (last edited 2023-06-08 00:44:38 by DominicRicottone)