[R] Cannot read XPT file using foreign package
fisher at plessthan.com
Sat Oct 5 02:01:03 CEST 2013
I looked at
and it is a bit difficult to decipher. I then replaced the string "^@" in the file contents with "!". There is some concordance with he sample text shown in support.sas.com/techsup/technote/ts140.pdf but I don't know exactly how much concordance is expected. The time stamp in the file is today so I assume that the file was created today.
You asked "why [I] think this is a file that follows the format" -- I did not make that assumption; I merely attempted to read an XPT file with read.xport and it failed.
Could there be an issue with the version of SAS (which appears to be 6.06) -- they are now up to version 9 (for Windows - I don't know the version # for UNIX).
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
On Oct 4, 2013, at 4:47 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 13-10-04 6:50 PM, Dennis Fisher wrote:
>> OS X 10.8
>> R 3.0.1
>> foreign 0.8-55 (2013-09-02)
>> I received a SAS XPT file that I cannot read using the foreign package.
>> The command:
>> results in the following message:
>> Error in lookup.xport(file) : file not in SAS transfer format
>> I am able to read the file successfully using StatTransport so it appears that the file is OK.
>> When I examine the file using "more", the first few lines look like this:
>> HEADER RECORD*******MEMBER HEADER RECORD!!!!!!!000000000000000001600000000140
>> HEADER RECORD*******DSCRPTR HEADER RECORD!!!!!!!000000000000000000000000000000
>> SAS SAS SASDATA 6.06 bsd4.2 !04Oct13:11:15:5904Oct13:11:15:59
>> HEADER RECORD*******NAMESTR HEADER RECORD!!!!!!!000000000500000000000000000000
>> !^A!^H!^ASubject Subject BEST !^L! !
>> !^A!^H!^BPeriod Period BEST !^L! !^H!
>> Of course, I can use StatTransport to write the file to another format. However, I would like to understand why the foreign package is unable to process the file.
> That file doesn't follow the documented format linked to from ?read.xport. You'll have to ask SAS why their documentation is incorrect, or ask yourself why you think this file is a file that follows that format when it doesn't.
> Duncan Murdoch
More information about the R-help