Differences between revisions 3 and 4
Revision 3 as of 2020-05-29 13:39:14
Size: 1659
Comment:
Revision 4 as of 2021-03-16 17:08:35
Size: 1697
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from StataFileIO

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 import all columns as string variables, as opposed to guessing the type of columns, use option allstring.

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)