Skip to content

sas7bdat: write 64KB pages by default - #417

Merged
evanmiller merged 1 commit into
WizardMac:devfrom
hadley:sas-page-size-64k
Oct 20, 2026
Merged

evanmiller merged 1 commit into
WizardMac:devfrom
hadley:sas-page-size-64k

Conversation

@hadley

@hadley hadley commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

馃 Written by AI 馃

ReadStat hardcodes a 4KB page size when writing sas7bdat files, a convention dating from 32-bit Windows SAS. Modern SAS chooses the page size at file-creation time based on observation length, engine, and OS, and in practice lands on 8-64KB:

Writing 64KB pages matches what modern SAS produces and reduces per-page overhead 16x on large files (fewer page reads/seeks for readers, less page-header bookkeeping for writers). ReadStat's reader already accepts page sizes up to 16MB, so files written with this change remain readable by older ReadStat versions, and SAS itself supports 64KB pages natively.

Tested by round-tripping a 2M-row dataset through ReadStat's sas7bdat writer and reader: the written file has a 65536-byte page size and reads back identically. (Note: make check's test_readstat segfaults immediately on macOS arm64 both with and without this change, so I couldn't use it for validation.)

Modern SAS selects page sizes of 8-64KB depending on observation length
(with 64KB typical on current Windows/UNIX releases), while ReadStat has
hardcoded a 4KB default inherited from older 32-bit Windows conventions.
Larger pages reduce per-page overhead when reading and writing large
files (16x fewer page seeks/reads) and match what SAS itself produces
today.
@evanmiller
evanmiller merged commit 4d7587e into WizardMac:dev Oct 20, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants