[R] things that are difficult/impossible to do in SAS or SPSS but simple in R

Max Kuhn mxkuhn at gmail.com
Thu Jan 17 02:22:28 CET 2008

Factors have huge benefits over character data in SAS. For a series
regulatory filings, I had miles of SAS code to compute KxK tables
where all the cells must show up. For example, if one of the levels of
one of the variables was never observed, the corresponding row or
column would not show up in proc freq. The basic way around this was
to get all possible combinations of the variables and assign each cell
to have a row count of 0.00000001. Then you would merge this data with
the real counts. The missing row/columns would show up since they had
data, but it was below the printing threshold of proc freq. Hoepfully,
they have added a feature to do this.

You can imagine how much work the test documents were for that macro.
Contrast that with a simple call to the canned table function in R.
And people think that SAS has an advantage when it comes to

Also, I always think about having a real programming language with
namespaces, object-orientation, real functions, scoping, etc. This is
very important and often under-recognized. For example, I've seen SAS
macros called inside of SAS macros; this can be dangerous because the
data lives in the same area and if two macros had a dataset with the
same name the data would be over-written.



More information about the R-help mailing list