[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;
     a='a';
     b='bb';
     length c d $2;
     c='c';
     d=' d';
     x=3.1;
     output;
run;
proc print data=foo;
run;

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

proc contents data=foo;
run;


---------- 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
status
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
-- 
--------------------------------------
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