*! version 1.1.2 24may2026 Author: Eric A. Booth

Title

convertanything -- Multi-format importer and converter for Stata. Detects file types and converts them to .dta format.

Syntax

convertanything using path [, options]

saving(dir) destination directory for .dta output

recursive recurse into subdirectories; mirrors tree into saving()

skip(namelist) subdir names to skip when recursive (default: _converted _archive)

allsheets export every Excel worksheet as a separate .dta

replace overwrite existing .dta files

clear clear memory before each import

extension(list) restrict to these extensions (e.g., "csv xlsx")

verbose show per-file progress

compress compress every converted dataset

cleannames lowercase + Stata-legal variable names

destring auto-destring with ignore("$,%") and percent

Description

convertanything is a utility for Stata data ingestion that automatically determines the correct
command (import excel, import delimited, use, etc.) based on the file extension.

It includes "bulletproof" features to ensure messy raw data are converted into clean, optimized
Stata datasets. Paths with spaces (e.g., Google Drive's "Shared drives/Data and Research Team") are handled safely throughout.

When recursive and saving() are both specified, the source directory tree is
mirrored into the destination: src/2019/file.xls → saving/2019/file.dta.
Without saving(), converted files are written next to their source.
Subdirectories named in skip() are not entered (default protects _converted and
_archive from re-processing or infinite recursion).

Options

saving(path) specifies the destination folder. If omitted, converted files are saved in the same directory as the source files.

recursive triggers a deep search of subdirectories.

allsheets is specific to .xls and .xlsx files. It saves each worksheet as filename_sheetname.dta.

compress applies Stata's compress command to every dataset before saving.

cleannames ensures all variable names are lowercase and pass Stata's naming conventions.

destring runs destring with ignore("$,%") and percent options.

Examples

Example 1: Basic file conversion with cleaning

. convertanything using "mydata.csv", replace clear cleannames destring compress

Example 2: Pass 0 bulk-convert for a datashare project (standard pattern)

. dswipe "$"

. convertanything using "$", recursive saving("$") ///

skip("_converted _archive") allsheets cleannames destring compress clear replace

Example 3: Batch convert a folder, flat output

. convertanything using "C:/Data/Comptroller/", extension(csv) saving("C:/Stata_Data/") replace clear

Example 4: Recursive deep-clean with verbose output

. convertanything using "Downloads/Raw_Data/", recursive verbose replace clear compress destring

Author

Eric A. Booth

Texas 2036

Email: eric.a.booth@gmail.com

GitHub: www.github.com/ericabooth