Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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-sys crate exposes the full ReadStat API — all 125 functions across all formats. However, this CLI only supports SAS .sas7bdat files. SPSS and Stata support is a possible future addition, but is not planned at this time — if you need those formats today, the readstat-sys bindings 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 stdout
  • convert — 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-write for 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