[R] Importing SAS transport data

Martyn Plummer plummer at iarc.fr
Thu Apr 7 12:08:07 CEST 2005


On Wed, 2005-04-06 at 17:38 -0700, Dennis Fisher wrote:
> I have encountered a problem reading SAS transport files on both a Mac 
> (OS X) and Linux (RedHat 9), both using R2.0.1.
> 
> After loading "foreign", the command:
> read.xport("V1622101_050304.xpt")
> 
> yields:
> Error in lookup.xport(file) : File not in SAS transfer format
> 
> In Linux, I can "cat" the file.  The first few lines are:
> **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED** 
> **COMPRESSED********LIB CONTROL WIN_PRO<BC>^BWIN^@8 
> SAS8.2<BC><AB>D701DATALIB 
> ACM<BC><9B>VC30<BC><81>CC14537<BC><85>RL507<BC><87>1<BC><87>S 0  0  20 
> CHAR
> 
> In contrast, I can read.xport a different file successfully.
> That file (and others that I can import successfully) contains the 
> following first line:
> HEADER RECORD*******LIBRARY HEADER 
> RECORD!!!!!!!000000000000000000000000000000  SAS     SAS     SASLIB  
> 6.12    WIN_NT                          
> 21OCT02:13:30:0721OCT02:13:30:07
> 
> I know little about SAS but I wonder whether the problem relates to the 
> export characteristics of different versions of SAS.  If so, it appears 
> that read.xport may not work with newer versions of SAS.  If so, is 
> there a new function to read SAS transport files?
> 
> Thanks for any possible help.

There are two transport formats for SAS.  The older one (XPORT) is an
open format ( http://support.sas.com/techsup/technote/ts140.html ).  The
newer one (CPORT) has been available since SAS version 6. It is a
proprietary format, so there is little chance of being able to read this
data into R.

NB The CPORT transpor format is in addition to, rather than a
replacement for, the XPORT format. You can still create XPORT transport
files in the latest version of SAS, so this is what you need to ask for.

Martyn




More information about the R-help mailing list