Skip to content

Stop reading XPORT rows at the next dataset - #447

Open
yucheng-du wants to merge 2 commits into
WizardMac:devfrom
yucheng-du:fix/stop-xport-at-next-member
Open

yucheng-du wants to merge 2 commits into
WizardMac:devfrom
yucheng-du:fix/stop-xport-at-next-member

Conversation

@yucheng-du

Copy link
Copy Markdown

A SAS V5 file in tidyverse/haven#795 contains 31 observations in its first dataset. ReadStat returned 239 because it read the next dataset's headers and values as more observations.

Stop after the first member when the row count is unknown. Check the aligned member and descriptor records and the SAS dataset marker so ordinary character values can still contain header text. This also handles V8 files with a blank observation count.

The 31 rows now match foreign::read.xport() on the reported file. make check passes, including tests for padding, header text in data, row offsets, and limits.

Addresses the first-member parsing part of #412. Selecting other members remains open.

Comment thread src/sas/readstat_xport_read.c Outdated
if (matches < 2) {
return READSTAT_ERROR_PARSE;
const char blank_obsv8[] = "HEADER RECORD*******OBSV8 HEADER RECORD!!!!!!!"
" ";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should add a comment for char length here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment in ea60b93 explaining that the 15 spaces are the blank observation count.

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