Skip to content

Fix SAS readability issue in written 32-bit sas7bdat - #421

Merged
evanmiller merged 1 commit into
WizardMac:devfrom
hpoettker:fix-32bit-sas7bdat
Oct 27, 2026
Merged

evanmiller merged 1 commit into
WizardMac:devfrom
hpoettker:fix-32bit-sas7bdat

Conversation

@hpoettker

Copy link
Copy Markdown
Contributor

Problem

32-bit SAS data files (sas7bdat) written by ReadStat are currently not correctly readable by SAS.

Currently, SAS will load the file without aborting with an error but it will start reading uncompressed row data from the wrong offset. As it starts 4 bytes too early, all strings are seemingly prefixed with a short bit of line noise and truncated if filling almost the whole width of the text column. Numbers suffer from the same problem and are in effect unrecognizable.

The Fix

The PR proposes to change the writing of the row size subheader for 32-bit SAS data files such that

  • a row counter is moved to its position in SAS generated files,
  • a mystery flag/offset is switched from 1 to 5.

Moving the row counter doesn't seem to have an actual effect with SAS but it aligns the produced file format with SAS, which is a good thing.

Switching the mystery flag/offset is the actual fix. Increasing it by 4 for 32-bit SAS data files shifts the offset for reading uncompressed rows to the right position as SAS now displays the files as expected. The value 5 is also what's produced in 32-bit files generated with SAS on Windows.

@evanmiller
evanmiller merged commit 2b8ae11 into WizardMac:dev Oct 27, 2026
14 checks passed
@hpoettker
hpoettker deleted the fix-32bit-sas7bdat branch October 27, 2026 18:49
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