You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a XPORT file using 'write_export' with option 'file_format_version=8', the resulting file is not correctly read in by SAS v9.0401M8. All filename and variable name information is correctly read into SAS but SAS reports 0 observations. This issue does not occur when using 'file_format_version=5'.
Where '1' is the number of observations in the example. I have verified this using SAS datasets containing 3, 1_000_000 (more than 5 decimal digits to store), and 10_000_000_000 (more than 10 decimal digits to store). Based on this, I believe that the 15 digits following the '!!!' are used to store the number of observations. Example hexdump output for the 10_000_000_000 observation XPORT file create by SAS is provided below.
The other item of note is that SAS pads before and after the observation count with spaces (0x20) rather than zeros (0x30). It has seemed to accept either given that front padding with 0s is equivalent numerically. I tested this using the the 3 observation dataset. Simply changing the appropriate '30' to '33' and leaving all other readstat formatting alone allowed SAS to read it properly.
Code location
I believe the row_count variable exists and just needs to be added to the xport_write_obs_header_record function in src/sas/readstat_xport_write.c. It may also be possible to read in the observation count data from the header, when it exists, in the readstat_xport_read module.
The text was updated successfully, but these errors were encountered:
Issue:
When creating a XPORT file using 'write_export' with option 'file_format_version=8', the resulting file is not correctly read in by SAS v9.0401M8. All filename and variable name information is correctly read into SAS but SAS reports 0 observations. This issue does not occur when using 'file_format_version=5'.
Identified Cause:
Using the same source SAS dataset, I created a v8 XPORT file using readstat and SAS v9.0401M8. There was only a single (meaningful) difference between the files which was in the Observation header. The SAS version includes an observation count in the header, similar to how NAMESTR and LABEL headers include variable counts. This is not spelled out clearly in the SAS documentation at https://support.sas.com/content/dam/SAS/support/en/technical-papers/record-layout-of-a-sas-version-8-or-9-data-set-in-sas-transport-format.pdf.
The description on Page 7 for the header simply shows:
However, examples on Page 8 and following show:
Where '1' is the number of observations in the example. I have verified this using SAS datasets containing 3, 1_000_000 (more than 5 decimal digits to store), and 10_000_000_000 (more than 10 decimal digits to store). Based on this, I believe that the 15 digits following the '!!!' are used to store the number of observations. Example hexdump output for the 10_000_000_000 observation XPORT file create by SAS is provided below.
The other item of note is that SAS pads before and after the observation count with spaces (0x20) rather than zeros (0x30). It has seemed to accept either given that front padding with 0s is equivalent numerically. I tested this using the the 3 observation dataset. Simply changing the appropriate '30' to '33' and leaving all other readstat formatting alone allowed SAS to read it properly.
Code location
I believe the row_count variable exists and just needs to be added to the
xport_write_obs_header_record
function insrc/sas/readstat_xport_write.c
. It may also be possible to read in the observation count data from the header, when it exists, in thereadstat_xport_read
module.The text was updated successfully, but these errors were encountered: