SPSS .sav & .zsav Codecs
Streaming binary reader and writer for classical and zlib-compressed SPSS system files.
Clean-Room GNU PSPP Spec VerifiedCrates: statcraft_io
1. Binary Record Structure#
The statcraft_io crate implements a complete binary parser and writer for SPSS system files without external C libraries:
- Record Type 1: General file header (release number, weight variable index, case count, timestamp);
- Record Type 2: Variable dictionary (type, print/write format, 8-character legacy name);
- Record Type 3/4: Value labels dictionary and variable assignment bindings;
- Record Type 7: Extended metadata (long variable names, UTF-8 character encoding, measure level, display width).
2. Compression Schemes (Bytecode & ZLIB)#
- Uncompressed & Bytecode: Standard 8-byte chunks packed into 8-element instruction blocks;
- Zstandard / ZLIB (.zsav): Block-based stream decompression enabling sub-second loads for million-row files.
3. Lossless Roundtrip Guarantee#
Files written by StatCraft open flawlessly in IBM SPSS Statistics 20–29 with all variable labels, categorical coding schemes, and missing value definitions 100% preserved.
Canonical SPSS Syntax Example
SPSS SYNTAX (.SPS)
| 1 | GET FILE='survey_2026.sav'. |
| 2 | SAVE OUTFILE='survey_cleaned.zsav' |
| 3 | /COMPRESSED. |