[R] SAS and R

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Apr 26 16:34:12 CEST 2002


"Peter Flom" <flom at ndri.org> writes:

> Hello
> 
> I am sure this is elementary, but I can't figure it out.....
> 
> I am using SAS v8.2 and R 1.4.1 on a Windows platform.
> 
> I have a large (6 megabyte) file in .sd2 format.  I want to import it into R.
> If necessary, I can create a smaller file, as I don't need all the variables that are in this file
> 
> I downloaded the package foreign.   I then tried to use PROC CPORT in SAS to create a transport file.  It gave no error message, but I cannot find the file it wrote.  I also tried the SAS Export Wizard, but this didn't work.
> 
> What's the best way to do this?  
> 
> More specifically
> 
> 1) How do I import any .sd2 file to R ?

You don't. Not even SAS itself can do that, except on the same platform.

PROC CPORT is the wrong way. The template for creating files that
read.xport will accept is something like this:

libname peter xport "dataset.xpt";
DATA peter.foo;
  SET sasuser.bar;
run;

You may want to change "dataset.xpt" to something with a full path so
you can find it again (putting files in seemingly arbitrary locations
is a common feature of so-called user-friendly software...).

> 2) Is it better to create and import small files as needed, or one huge file which would contain all the data?

There are pros and cons. Small files put less strain on a small
system, but you need to be more careful in keeping them all up to date
if the database changes.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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