[R] Executing SAS Codes in R

Marc Schwartz marc_schwartz at me.com
Thu Nov 8 16:40:34 CET 2012


On Nov 8, 2012, at 9:09 AM, Peter Maclean <pmaclean2011 at yahoo.com> wrote:

> The answer I got from my previous questions suggeted how to read SAS data into R. That was not the question. I want to execute/evaluate SAS code inside R environment. I have SAS data and SAS codes but I have no access to SAS software. In my study, I want to replicate everything defined by the SAS code. 



The answer to running SAS code inside R was answered, with a pretty clear no:

  https://stat.ethz.ch/pipermail/r-help/2012-November/328405.html

The other responses were generally tongue in cheek responses pertaining to the above inability (eg. You can run SAS code in R by reversing the way in which you run R code in SAS). 

You can call SAS from within R by using the system() command as was noted in one reply and SAS has an ability to run R from within a SAS session via a similar method of executing an external program, but they do not natively interpret and execute the other language.

If you are looking to **translate** your SAS code to R code, so that you can accomplish similar analyses in R, then you should be looking at a reference such as:

R for SAS and SPSS Users
by Bob Muenchen
http://www.amazon.com/SAS-SPSS-Users-Statistics-Computing/dp/0387094172

I am not sure that I saw a definitive response to reading SAS datasets into R, but a more recent option, which is based upon a reverse engineering of the SAS data set structure would be Matt Shotwell's sas7bdat CRAN package:

  http://cran.r-project.org/web/packages/sas7bdat/index.html


Regards,

Marc Schwartz




More information about the R-help mailing list