Open DanChaltiel opened 10 months ago
Hi, Dan It seems that there is an issue with the "test.xpt" file that was created using the {write_xpt} function.
As "$Date." is not a recognizable format for character variable in SAS/XPT, it should be "Date.". Maybe this affect the creation?
Hi Kevin,
Yes, the "test.xpt" file has the same problem as the output of a 3rd party software which generates flawed XPT files in some settings.
Here, my object x
is misconstructed as it holds a character vector of class Date while Dates should always be numeric.
The present issue is about error management in read_xpt()
so that one can overcome such flawed XPT files.
Most R users cannot correct XPT files so if haven do not let us read them we are unfortunately helpless.
I'm not sure write_xpt()
should be corrected for that matter, as this flawed R object x
should never occur naturally.
Agree, it seems the current conversion tool doesn't works very well.
Hi,
In some 3rd party-generated XPT files, Dates may be misconstructed, with the number of days being encoded as a string.
This doesn't cause any trouble when using SAS or other software (e.g. https://stattransfer.com/), but it causes instant failure when using {haven}.
Presently, the whole reading process throws an error if one single column is corrupt, while IMHO it should only throw a warning on the column and deliver it raw. This way one could try to fix the issue manually.
Here is a reprex:
Created on 2023-12-18 with reprex v2.0.2
This issue is related to https://github.com/tidyverse/haven/issues/536, but with a reprex this time :-)