readstat-cli
Binary crate producing the readstat CLI tool for converting SAS binary files (.sas7bdat) to other formats.
Note: The ReadStat C library supports SAS, SPSS, and Stata file formats. The
readstat-syscrate exposes the full ReadStat API — all 125 functions across all formats. However, this CLI only supports SAS.sas7bdatfiles. SPSS and Stata support is a possible future addition, but is not planned at this time — if you need those formats today, thereadstat-sysbindings already expose the complete SPSS (.sav,.zsav,.por) and Stata (.dta) C API to build on.
Subcommands
metadata— Print file metadata (row/var counts, labels, encoding, format version, etc.)preview— Preview first N rows as CSV to stdoutconvert— Convert to CSV, Feather, NDJSON, or Parquet (inferred from the output extension)
Key Features
- Column selection (
--columns,--columns-file) - Streaming reads with configurable chunk size (
--stream-rows) - Bounded parallel CSV/NDJSON/Parquet writing by default, with
--serial-writefor memory-sensitive workloads - Optional SQL queries via DataFusion (
--sql,--sql-file) - Parquet compression settings (
--compression,--compression-level)
With no --output, conversion writes CSV to stdout. Progress, logs, and other diagnostics go to stderr, so stdout can be piped safely. An explicit format must agree with .csv, .feather, .ndjson, or .parquet; unknown extensions and mismatches are errors.
The default CLI omits DataFusion to keep the binary and dependency graph small. Enable SQL when installing from Cargo with:
cargo install readstat-cli --features sql
Documentation
- CLI Cheatsheet — one-page printable overview of subcommands, flags, and common workflows
- Full CLI reference (docs/USAGE.md) — complete documentation with memory diagrams and metadata round-trip examples