There have been a number of posts on SAS Communities from users having trouble with converting XPORT files they have received.
Binary zeros in FORMAT/INFORMAT names.
https://communities.sas.com/t5/New-SAS-User/transporting-files-from-R-to-SAS/td-p/898017
Reading directly from ZIP file.
https://communities.sas.com/t5/SAS-Programming/Cannot-import-XPT-file-into-SAS/td-p/668444
Empty dataset issue
https://communities.sas.com/t5/New-SAS-User/SAS-Xport-Empty-Data-Set-File-Issue/td-p/765019
To help with reading such files I have created an %XPORT2SAS() macro.
https://github.com/sasutils/macros/blob/master/xport2sas.sas
Enhancements over XPT2LOC macro include:
- Detects and adapts to CPORT files.
- Handles zero variable and zero observation datasets.
- Handles extra LIBRARY records when reading multiple XPORT files together.
- Handles some file format errors generated by third party software.
- Invalid format specifications in LABELV9 records.
- Binary zeros in character fields.
- Allows forcing file to be read using RECFM=F.
- Needed when RECFM=N does not work properly.
- RECFM=F code will not conflict with any dataset variable names.
- Includes macro parameter validation.
- Allows saving metadata to a dataset.
- Allows saving generated code to a file.
- Uses system generated fileref names to avoid conflicts.
- Allows nliteral memnames in MEMLIST parameter.
- All code contained in single macro.
Please try it out and let me know if you find any issues with the code. Or have examples of XPORT files that have issues it cannot handle.
I am particularly interested in whether RECFM=N can be used to read from an XPORT file on MVS.