BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

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.  

 

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 0 replies
  • 349 views
  • 1 like
  • 1 in conversation