Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# haven (development version)

* Updated to ReadStat dev a4984d5.

* Fix issue writing SAV files with labels for string values longer than 8 bytes (#550).
* Fix issue reading SAS files with zero observations (#627).
* Fix issue writing XPT V8 datasets with long variable labels (#784).
* FIx issue reading SAV files where an MR set name contains a non-ASCII character (#788).

* `col_select` in the `read_*()` functions now correctly implements the
tidyselect interface. Columns will be returned in the order specified in
`col_select` and can be renamed, e.g. `col_select = c(new = old)` (#685).
Expand Down Expand Up @@ -39,7 +46,7 @@

# haven 2.5.5

* Updated ReadStat to fix stricter gcc diagnostics.
* Updated to ReadStat dev b2d5407 to fix stricter gcc diagnostics.

# haven 2.5.4

Expand Down
3 changes: 3 additions & 0 deletions src/readstat/readstat_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,8 @@ const char *readstat_error_message(readstat_error_t error_code) {
if (error_code == READSTAT_ERROR_BAD_TIMESTAMP_VALUE)
return "The provided file timestamp is invalid";

if (error_code == READSTAT_ERROR_BAD_MR_STRING)
return "A multi-response set record is invalid";

return "Unknown error";
}
2 changes: 1 addition & 1 deletion src/readstat/sas/readstat_sas7bdat_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ static readstat_error_t sas7bdat_validate_column(col_info_t *col_info) {
}
}
if (col_info->type == READSTAT_TYPE_STRING) {
if (col_info->width > INT16_MAX || col_info->width == 0) {
if (col_info->width > INT16_MAX) {
return READSTAT_ERROR_PARSE;
}
}
Expand Down
23 changes: 14 additions & 9 deletions src/readstat/sas/readstat_xport_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,21 @@ static readstat_error_t xport_write_record(readstat_writer_t *writer, const char
return retval;
}

static readstat_error_t xport_write_header_record_v8(readstat_writer_t *writer,
static readstat_error_t xport_write_header_record_obsv8(readstat_writer_t *writer,
int row_count) {
char record[RECORD_LEN+1];
snprintf(record, sizeof(record),
"HEADER RECORD*******OBSV8 HEADER RECORD!!!!!!!" "%15d",
row_count);
return xport_write_record(writer, record);
}

static readstat_error_t xport_write_header_record_labelv8(readstat_writer_t *writer,
xport_header_record_t *xrecord) {
char record[RECORD_LEN+1];
snprintf(record, sizeof(record),
"HEADER RECORD*******%-8sHEADER RECORD!!!!!!!" "%15d" "%15d",
xrecord->name, xrecord->num1, xrecord->num2);
"HEADER RECORD*******%-8sHEADER RECORD!!!!!!!" "%-5d",
xrecord->name, xrecord->num1);
return xport_write_record(writer, record);
}

Expand Down Expand Up @@ -167,7 +176,7 @@ static readstat_error_t xport_write_variables(readstat_writer_t *writer) {
if (any_has_long_format) {
strcpy(header.name, "LABELV9");
}
retval = xport_write_header_record_v8(writer, &header);
retval = xport_write_header_record_labelv8(writer, &header);
if (retval != READSTAT_OK)
goto cleanup;

Expand Down Expand Up @@ -357,11 +366,7 @@ static readstat_error_t xport_write_namestr_header_record(readstat_writer_t *wri

static readstat_error_t xport_write_obs_header_record(readstat_writer_t *writer) {
if (writer->version == 8) {
xport_header_record_t xrecord = {
.name = "OBSV8",
.num1 = writer->row_count
};
return xport_write_header_record_v8(writer, &xrecord);
return xport_write_header_record_obsv8(writer, writer->row_count);
}
xport_header_record_t xrecord = {
.name = "OBS"
Expand Down
Loading
Loading