*! version 0.1.0 14aug2026

dbf2stata

Batch-convert DBF files to Stata .dta format using the dbf2stata Python package.

Syntax

dbf2stata
[, inputdir(path) outputdir(path) keepcase replace]

Description

dbf2stata converts every .dbf or .DBF file in a folder to Stata .dta format.

With no options, dbf2stata opens a file chooser. Select any DBF file in
the folder to be converted. Every DBF file in that folder is then processed.

By default, .dta files are saved in the same folder as the source DBFs and
variable names are converted to lowercase.

The Stata command uses the public dbf2stata Python package as its
conversion engine.

Requirements

Stata 16 or newer with Python 3.10 or newer configured for Stata.

The dbf2stata Python package must be installed in the Python environment
used by Stata. The companion dbf2stata_setup command can
install this dependency for the user.

Installation

Until the SSC package is published, install the current SSC candidate with:

. net install dbf2stata, from("https://raw.githubusercontent.com/WilliamDormechele/dbf2stata/ssc-candidate-2026-08-14-r2/stata")

After installation, start the command with:

. dbf2stata

Before opening a DBF, dbf2stata checks whether its Python engine is
available. If the Python package is missing, the command stops with clear
instructions to run:

. dbf2stata_setup

dbf2stata_setup uses the exact Python executable already being used by
Stata and installs the required Python package from PyPI. The main
dbf2stata command never silently installs or upgrades Python packages.

Users who want to check Stata's Python configuration can type:

. python query

For setup details, see dbf2stata_setup.

SSC installation

The package is being submitted to the Statistical Software Components (SSC)
Archive. After SSC accepts and publishes it, installation will be:

. ssc install dbf2stata

After installation, type dbf2stata. If the external Python dependency is
not yet available, dbf2stata will direct the user to
dbf2stata_setup.

Platform support

The Python conversion engine is tested on Windows, Linux, macOS Apple Silicon,
and macOS Intel.

The Stata command uses Stata's Python integration, the Stata Function Interface,
the operating system's file dialog, and Python cross-platform path handling.

The setup command does not hard-code Windows, macOS, or Linux Python paths.
Instead, it invokes pip through sys.executable, which is the Python
interpreter currently running inside Stata.

The Windows licensed-Stata integration has been tested directly. A portable
licensed-Stata smoke test is included for additional Stata installations,
including Stata for Mac.

Options

inputdir(path) specifies the folder containing the DBF files and bypasses
the file chooser.

outputdir(path) specifies another output folder. If omitted, output is
saved in the DBF input folder.

keepcase retains the field-name case stored in the DBF. If omitted,
variable names are converted to lowercase.

replace overwrites existing .dta files. Without replace, existing
.dta files are protected from overwrite.

Examples

Open the file chooser:

. dbf2stata

Specify the input folder:

. dbf2stata, inputdir("C:\data\dbfs")

Specify another output folder:

. dbf2stata, inputdir("C:\data\dbfs") outputdir("C:\data\stata")

Overwrite existing .dta files:

. dbf2stata, inputdir("C:\data\dbfs") replace

Retain DBF field-name case:

. dbf2stata, inputdir("C:\data\dbfs") keepcase

Stored results

dbf2stata stores the following in r():

r(files) number of DBF files found

r(converted) number successfully converted

r(failed) number that failed

r(records) total records written

Author

William Dormechele

University of East Anglia, United Kingdom

Links

Python package:
PyPI

Source code and issue tracker:
GitHub

License

MIT License.

Also see

dbf2stata_setup