Skip to content

WIP: Support converting CSV with JSON metadata to sas7bdat - #427

Draft
FlipperPA wants to merge 1 commit into
WizardMac:devfrom
FlipperPA:csv-to-sas7bdat
Draft

FlipperPA wants to merge 1 commit into
WizardMac:devfrom
FlipperPA:csv-to-sas7bdat

Conversation

@FlipperPA

Copy link
Copy Markdown
Contributor

Add a read_csv module for sas7bdat output, alongside the DTA and SAV ones. Numeric columns are written as doubles: DATE as days since 1960-01-01 (DATE9.), DATE_TIME as seconds since 1960 without leap seconds (DATETIME19.), TIME as seconds since midnight (TIME8.), and other numbers unscaled with Fw.d or BEST12. Values listed under "missing" become SAS special missing values .A, .B, ... Value labels are not written, since a sas7bdat file keeps them in a separate SAS catalog; the CLI warns instead.

For SAS output, read_csv passes each variable's format as its value-label name, as the SAS readers do, rather than the column name, which the writer would otherwise take as the column's format.

readstat_parse_csv no longer crashes when the output format is not supported: it called csv_free() on a parser csv_init() had not set up.

Document the SAS metadata in variablemetadata_schema.json and the README, and add a round-trip test that runs when the CSV reader is built.

Add a read_csv module for sas7bdat output, alongside the DTA and SAV ones.
Numeric columns are written as doubles: DATE as days since 1960-01-01
(DATE9.), DATE_TIME as seconds since 1960 without leap seconds
(DATETIME19.), TIME as seconds since midnight (TIME8.), and other numbers
unscaled with Fw.d or BEST12. Values listed under "missing" become SAS
special missing values .A, .B, ... Value labels are not written, since a
sas7bdat file keeps them in a separate SAS catalog; the CLI warns instead.

For SAS output, read_csv passes each variable's format as its value-label
name, as the SAS readers do, rather than the column name, which the
writer would otherwise take as the column's format.

readstat_parse_csv no longer crashes when the output format is not
supported: it called csv_free() on a parser csv_init() had not set up.

Document the SAS metadata in variablemetadata_schema.json and the README,
and add a round-trip test that runs when the CSV reader is built.
@FlipperPA
FlipperPA marked this pull request as draft November 2, 2026 21:35
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.

1 participant