openstatspec/spss-sav

PHP reader and writer for IBM SPSS Statistics SAV and ZSAV files

Maintainers

Package info

github.com/OpenStatSpec/php-spss

pkg:composer/openstatspec/spss-sav

Transparency log

Statistics

Installs: 80

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

3.1.0 2026-08-03 09:32 UTC

README

Latest Version on Packagist QA Total Downloads License

A PHP library for reading and writing SPSS / PSPP SAV and ZSAV data files.

Maintained by OpenStatSpec. This project continues the MIT-licensed codebase created by Vladyslav Korniienko. The stable PHP namespace remains SPSS\ for compatibility.

Requirements

  • PHP 8.4.1 or newer
  • mbstring extension
  • bcmath extension
  • zlib extension

Installation

composer require openstatspec/spss-sav

Usage

Read a file into the v3 typed dataset model:

use SPSS\Sav\Reader;

$dataset = Reader::fromFile('/path/to/input.sav')->readDataset();

foreach ($dataset->rows() as $row) {
    // Values follow the order of $dataset->variables().
}

Write a typed dataset:

use SPSS\Sav\Writer;

$writer = new Writer($dataset);
$writer->save('/path/to/output.sav');
$writer->close();

Numeric null cells represent SPSS system-missing values. Strings must always be strings; an empty string is an ordinary value. SPSS dates, times, and currencies remain numeric values whose presentation is described by VariableFormat.

See the v3 typed Dataset guide for creating datasets, metadata, SAV/ZSAV support, and migration from the legacy array API. The older low-level examples remain available during migration.

Changelog

Please have a look in CHANGELOG

Development

Install the locked development dependencies:

composer install

The install command activates the versioned pre-push hook in .githooks. It runs the same complete QA suite used in CI before every push. You can also run the checks directly:

composer qa
composer qa:release

composer qa validates and audits Composer dependencies, lints PHP syntax, checks coding style, runs Rector in dry-run mode, performs PHPStan level 6 analysis with strict rules, and executes the PHPUnit 13 tests. composer qa:release additionally enforces:

  • at least 85% executable-line coverage;
  • at least 74% branch coverage across the deterministic branch shards;
  • Infection's mutation-testing threshold, with timeouts counted against the score and capped;
  • bidirectional SAV/ZSAV interoperability with R/haven.

The release suite requires Xdebug coverage plus Rscript with the haven package. The pre-push hook runs this complete release suite. Run composer fix to apply safe Rector and coding-style fixes.

See Quality and release gates for individual commands, report locations, and the rationale for each threshold.

License

Licensed under the MIT license.