[R] New utility: sas2r

Rolf Poalis rolf at biostatistics.dk
Thu Apr 1 07:19:49 CEST 2004


Dear R users,

Biostatistics Denmark would like to annouce the availability of the
new utility: sas2R --- a SAS to R parser.

For almost 40 years SAS has been the primary tool for statisticians
worldwide and its easy-to-learn syntax, unsurpassed graphical system,
powerful macro language and recent graphical user interfaces have made
SAS the number one statistical software choice for both beginners and
advanced users.

We find it unnecessary for users to learn yet another statistical
software package and have decided to make SAS available to a larger
audience by providing a SAS interface to the free statistical software
package R. It is our hope that the sas2R utility eventually will prove
as powerful as the true SAS system and we believe that this release
marks the beginning of a new era for R.

The sas2R utility consists of a parser (written in perl) that rewrites
the SAS code as R code and a package (sastor) of utility functions
that are needed to run the parsed code. sastor consists mainly of
functions for presenting output in the familiar and canonical SAS
format.

Download the utility at: http://www.biostatistics.dk/sas2r/index.html

Example: The following SAS code:

DATA test;
    INPUT x y f$;
    CARDS;
    1 2 m
    1 3 m
    2 4 m
    2 4 f
    1 5 m
    4 3 f
    3 2 f
;

PROC PRINT DATA=test;
  VAR x;    

PROC REG DATA=test;
  MODEL y = x;

RUN;  

        
is converted to 

library(sastor)
test <- data.frame(x = c(1, 1, 2, 2, 1, 4, 3), y = c(2, 3, 4, 4, 5, 3, 2), f = c("m", "m", "m", "f", "m", "f", "f"))
sas.print.print(test[, c("x"), drop=F])
sas.print.reg(lm(y ~ x, data=test))


which produces the following output:


The SAS2R System

Obs x
1   1
2   1
3   2
4   2
5   1
6   4
7   3

The SAS2R REG Procedure

Analysis of Variance

Dependent Variable: y
                Df Sum Sq Mean Sq F value Pr(>F)
Model            1 0.5000  0.5000  0.3608 0.5742
Error            5 6.9286  1.3857               
Corrected Total  6 7.4286  1.8857               

Root MSE              1.17716    R-Square     0.0673
Dependent Mean        3.28571    Adj R-Sq    -0.1192
Coeff Var            35.82672                       


Parameter Estimates:
            DF  Estimate Std. Error t value Pr(>|t|)  
(Intercept)  1   3.7857     0.9438   4.011   0.0102 *
x            1  -0.2500     0.4162  -0.601   0.5742  




Here is the DESCRIPTION file for the package:

Package: sas2r
Version: 1.04
Title: SAS-to-R parser
Author: Rolf Poalis <rolf at biostatistics.dk>
Maintainer: Rolf Poalis <rolf at biostatistics.dk>
Description: A collection of functions for running SAS code in R.
Depends: R (>= 1.4.0), perl >= 5.8.0
License: GPL
URL: www.biostatistics.dk/sas2r/index.html

The following SAS procedures are parsed succesfully:

PROC CONTENTS
PROC CORR
PROC FREQ
PROC GLM
PROC MEANS
PROC NPAR1WAY
PROC PRINT
PROC REG
PROC SORT
PROC TTEST
PROC UNIVARIATE

The following SAS procedures work to some degree:

PROC GENMOD
PROC GPLOT
PROC MIXED

Please note:

o  All SAS procedure calls must include a DATA=

We look forward to receiving questions, comments and suggestions.

Rolf Poalis, Biostatistics Denmark




More information about the R-help mailing list