[R] Problem with read.xport() from foreign package

Don MacQueen macq at llnl.gov
Fri Apr 26 20:51:16 CEST 2002

I have found that data imported from SAS using read.xport() in 
package foreign (installed recently) does not match the original 
data, when the data consists of character strings that are only one 
character long.

Here is an example.

---- SAS commands to create the data ----
options nocenter;
data foo;
     length c d $2;
     d=' d';
proc print data=foo;

libname xpt xport 'xpt.foo';
proc copy in=work out=xpt memtype=data;
   select foo;

proc contents data=foo;

---------- output from proc print -------
OBS    A    B     C    D     X

  1     a    bb    c    d    3.1

--------- in R -------------
>  foo <- read.xport('xpt.foo')
>  foo
   A  B C  D   X
1   bb    d 3.1

note that neither foo$A nor foo$C has any data.

--------- version information ---------
NOTE: SAS (r) Proprietary Software Release 6.12  TS020

>  version
platform sparc-sun-solaris2.7
arch     sparc
os       solaris2.7
system   sparc, solaris2.7
major    1
minor    4.1
year     2002
month    01
day      30
language R

>  tmp <- installed.packages()
>  tmp[tmp[,1]=='foreign',,drop=FALSE]
      Package   LibPath                                       Version 
Priority      Bundle Depends
[1,] "foreign" "/erd/statistic/apps/R/R-1.4.1/lib/R/library" "0.4-9"

Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list