Stata 15 help for import_dbase

[D] import dbase -- Import and export dBase files

Syntax

Load a dBase file

import dbase [using] filename [, clear case(preserve|lower|upper)]

Save data in memory to a dBase file

export dbase [using] filename [if] [in] [, datafmt replace]

Save subset of variables in memory to a dBase file

export dbase [varlist] using filename [if] [in] [, datafmt replace]

If filename is specified without an extension, .dbf is assumed for both import dbase and export dbase. If filename contains embedded spaces, enclose it in double quotes.

Menu

import dbase

File > Import > dBase (*.dbf)

export dbase

File > Export > dBase (*.dbf)

Description

import dbase reads into memory a version III or version IV dBase (.dbf) file. export dbase exports data in memory to a version IV dBase (.dbf) file.

Stata has other commands for importing data. If you are not sure that import dbase will do what you are looking for, see [D] import and [U] 21 Entering and importing data.

Options for import dbase

clear specifies that it is okay to replace the data in memory, even though the current data have not been saved to disk.

case(preserve|lower|upper) specifies the case of the variable names after import. The default is case(preserve).

Options for export dbase

datafmt specifies that all variables be exported using their display format. For example, the number 1000 with a display format of %7.2f would export as 1000.00, not 1000. The default is to use the raw, unformatted value when exporting.

replace specifies that filename be replaced if it already exists.

Remarks

import dbase reads into memory a version III or version IV dBase (.dbf) file. If the dBase file is not version III or IV, import dbase will issue an error. dBase files are often paired with shapefiles for storing geometric location data. To import a shapefile, see [SP] spshape2dta.

export dbase exports data in memory to a version IV dBase (.dbf) file. dBase version IV has several file limitations when exporting.

1. Unicode is not supported. 2. Data cannot be more than 2 GB in size. 3. Data in memory must be less than 1,000,000,000 observations. 4. Data in memory must have less than 255 variables. 5. Variable names cannot exceed 10 characters in length. 6. Maximum string variable length is 255 characters. 7. Data width must be less than 4,000.

If your data in memory exceed any of these limits, export dbase will issue an error when trying to export the data.

Examples

Setup

. webuse autornd

Export the dataset to dBase file auto.dbf

. export dbase auto.dbf

Export only variables make and weight to auto2.dbf

. export dbase make weight using auto2.dbf

Import auto.dbf back into Stata

. import dbase auto, clear

List the data loaded from auto.dbf

. list


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