Differences between revisions 1 and 8 (spanning 7 versions)
Revision 1 as of 2020-01-15 17:21:00
Size: 1522
Comment:
Revision 8 as of 2022-09-25 19:59:21
Size: 1645
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:

<<TableOfContents>>
Line 17: Line 19:
To import all columns as string variables, as opposed to guessing the type of columns, use option `allstring`.
Line 23: Line 27:
For exporting reports into Excel, see [[StataReports#putexcel|documentation on putexcel]]. For details on exporting reports into Excel, see [[Stata/ReportFiles|here]].

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 details on exporting reports into Excel, see here.


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)