[R] Reading SAS SD2 Data file

Frank E Harrell Jr f.harrell at vanderbilt.edu
Thu Sep 27 21:12:49 CEST 2007


Marc Schwartz wrote:
> On Thu, 2007-09-27 at 19:56 +0200, Peter Dalgaard wrote:
>> Corey Sparks wrote:
>>> I am trying to read a SAS dataset into R that is in a .SD2 format, which
>>> is the Version 6 standard format from SAS.
>>>   
>> (for DOS/Windows, that is. The format was machine/OS dependent.)
> 
> That is still the case with the proprietary SAS formats. You can't read
> a SAS V9 file from Windows with SAS V9 on Linux, etc.
> 
>>> I see the routines that read the SAS XPORT format (foreign, Hmisc), but
>>> is there any way to read this one?
>>>   
>> Only commercial solutions. (SAS itself, DBMS/COPY, StatTransfer, ...) 
>> The actual format is a company secret, and noone has bothered to try and 
>> decipher it.
> 
> The XPORT (Transport) format is openly documented and is cross-platform
> compatible, which is why the FDA had standardized on it, for example.
> 
> There is the SAS System Viewer, which will open Windows based
> proprietary SAS files and enable you to save them to CSV files. It is
> _free_ and is available from here:
> 
> http://www.sas.com/apps/demosdownloads/sassystemviewer_PROD_9.1.3_sysdep.jsp?packageID=000313&jmpflag=N
> 
> It also runs under WINE on Linux, BTW.  :-)

Just note there is a bug in SAS Viewer if a character field has a comma 
or tab.  You'll get an invalid comma or tab-delimited file.  With all 
the $ it has SAS Institute is remarkably inept in certain areas (PROC 
EXPORT has the same bug).  Also SAS Viewer is much slower than 
Stat/Transfer.  By the way, Stat/Transfer will produce binary R data 
frames that can be load()ed.

Frank

> 
> HTH,
> 
> Marc Schwartz

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list