Saturday, April 9, 2016

datasciencecentral.com Call R and Python from base SAS, An Introduction to SAS for R Programmers

https://normaldeviate.wordpress.com/2013/01/19/bootstrapping-and-subsampling-p

https://www.datacamp.com/community/tutorials/functions-in-r-a-tutorial

http://www.r-bloggers.com/an-introduction-to-sas-for-r-programmers/art-i/


http://www.datasciencecentral.com/forum/topics/which-one-is-best-r-sas-or-python-for-data-science

Call R And Python From Base SAS | R-bloggers

www.r-bloggers.com/call-r-and-python-from-base-sas/

R bloggers
May 4, 2015 - Now, engineers at SAS have shared a method of calling R, Python and ... The first step is to install a Java class (shared on Github under an ... in R), which can then be used in a subsequent SAS PROC. ... A short while ago there was a discussion on linkedin about the use of SAS versus R for the enterprise.

DATA ANALYSIS: SAS vs. Python for data analysis

www.sasanalysis.com/2014/03/sas-vs-python-for-data-analysis.html

Mar 27, 2014 - SAS vsPython for data analysis. To perform data analysis efficiently, .... For SAS users - this might be a PROC GENMOD - which is already ...

Comparison with SAS — pandas 0.18.0 documentation

pandas.pydata.org/pandas-docs/stable/comparison_with_sas.html

Disk vs Memory; Data Interop ... Enter search terms or a module, class or function name. ... it is often convenient to specify it as a python dictionary, where the keys are the column ... SAS provides PROC IMPORT to read csv data into a data set.

Python Pandas vs SAS: Head to head data analysis (Part 1 ...

www.richardafolabi.com/.../python-pandas-vs-sas-head-to-head-data-ana...

Python Pandas vs SAS: Head to head data analysis (Part 1). October 16, 2015; 0 Comments; by @RichardAfolabi .... proc print data=work.newsalesemps;. run; ...

Tip: How to execute a Python script in SAS® Enterp... - SAS ...

https://communities.sas.com/t5/SAS.../Tip...Python...SAS.../223761

Running Python scripts within SAS Enterprise Miner enables you to use open source packages alongside the statistical, data mining and machine. ... This tip uses the Javaclass SASJavaExec.java and digitsdata_17_train.csv ... proc import.

Python - sasCommunity.org

www.sascommunity.org/planet/blog/category/python/

R, Python, and SAS: Getting Started with Linear Regression ...... *In SAS proc sql; select avg(weight) as Median from (select e.weight from class e, class d

SAS Vs. R Vs. Python - Which Analytics Tool Should I Learn?

www.analyticsvidhya.com › Big data

Mar 27, 2014 - SAS is easy to learn and provides easy option (PROC SQL) for .... I have seen this tool used in some university analytics classes along with R ...

Learning R Has Really Made Me Appreciate SAS ...

randyzwitch.com › Data Science

Jul 25, 2012 - proc summary data= hs0; var _numeric_; class prgtype; output .... Now that I know Python (and R), I can no longer use SAS at all, just too ...

Comparison of data analysis packages: R, Matlab, SciPy ...

https://brenocon.com/.../comparison-of-data-analysis-packages-r-matlab-...

Feb 23, 2009 - Python “immature”: matplotlib, numpy, and scipy are all separate libraries that ... SAS people complain about poor graphing capabilities. R vs. ...... nowSAS Component Language), and proc SQL and proc IML are different from ..... (I took my first programming class in 1977, and have programmed in more ...

2015 SAS vs. R Survey Results - Burtch Works

www.burtchworks.com/2015/05/21/2015-sas-vs-r-survey-results/

May 21, 2015 - 2015 SAS vs. ... SAS, but I'm taking an online R class now to stay current. .... Python can be used as both an analytic tool and a programming language ... It comes with a Proc R that let you run R code within the SAS language.


Call R and Python from base SAS

May 4, 2015
By 
(This article was first published on Revolutions, and kindly contributed to R-bloggers)

Since 2009, it has been possible to call R from SAS programs. However, this integration requires IML, an add-on matrix-object language for SAS which isn't available with all SAS installations and is separate from the standard SAS PROC execution model.
Now, engineers at SAS have shared a method of calling R, Python and other open-source tools using the Java connectivity provided in base SAS. The first step is to install a Java class (shared on Github under an Apache license), SASJavaExec.jar. Then, you can use the SAS Java Object in the DATA step to call out to a separately-authored R or Python. You should write the script to generate output in CSV format (using say write.table in R), which can then be used in a subsequent SAS PROC. Here's the example given for calling an R script:
R SAS
This example calls the R script digitsdata_svm.R, which calls the ksvm function from the kernlab package to perform a Support Vector Machine analysis. The R script in turns creates an output file predict_test_R.csv of classifications from the SVM.
You can find more details on how to call R and Python from the SAS data step at the link below.
SAS Support Communities: Open Source Integration Using the Base SAS Java Object (via Patrick Hall)


An Introduction to SAS for R Programmers

April 4, 2013
By 
(This article was first published on Revolutions, and kindly contributed to R-bloggers)

by Joseph Rickert
Life decisions are usually much too complicated to be attributed to any single cause, but one important reason that I am here at Revolution today is that I ignored suggestions from well-meaning faculty back in graduate school to work more in SAS rather than doing everything in R. There was a heavy emphasis on SAS then: the faculty were worried about us getting jobs. This was before the rise of the data scientist and the the corporate model my professors had in mind was: PhD statisticians do statistics and everyone else writes SAS code. I would not be surprised if this is still not the prevailing model in traditional Statistics programs. My bet is there are statisticians everywhere who have yet to come to grips with the concept of a “data scientist”. 
Anyway, because of the great cosmic balance, or the bad karma that comes from ignoring well-intentioned advice and the fact that there are quite a few companies out there that want to convert their SAS code to R, I occasionally get to look at SAS code. In the process of interviewing candidates for this kind of work it struck me that there are many people coming to data science through the programming or machine learning routes who have some R knowledge as well as experience with Java, Python and C++ who have never worked with SAS.
To this group I offer the following very brief “Introduction to SAS for R Programmers”. So what is SAS exactly? Originally, SAS  stood for “Statistical Analysis System”. Indeed, towards the beginning of his invaluable book, “R for SAS and SPSS Users”, Bob Muenchen characterizes SAS as a system for statistical computation that has five main components:
  1. A data management system for reading, transforming and organizing data (The Data Step)
  2. A large number of procedures (PROCs) for statistical analysis and graphics
  3. The Output Delivery System for extracting output from PROCs and customizing printed output
  4. A macro language for programming in the data step and calling PROCS
  5. The Interactive Matrix programming language (IML) for developing new algorithms
    SAS is not a single programming language.
It is an entire ecosystem of products (not all seamlessly integrated) that contains at least two languages! While becoming a competent SAS programmer clearly requires mastering an impressive number of skills, quite a bit can be accomplished in SAS with a basic knowledge of the Data Step and the more common procedures (PROCs) in the base and Stat packages. Moreover, as it turns out, these two foundational components of SAS are the very two things that an R programmer is likely to find most strange about SAS.
There is really only one data structure in SAS, a file with rows of observations and columns of variables that always gets processed by means of an implied loop. A Data Step “program” starts with the first row of a SAS file executes all of the code it encounters until it comes to a run; statement then looks at the second row of the file and runs through the code again. The Data Step proceeds sequentially through the entire file in this fashion. An excellent presentationfrom Steven J. First illustrates the process nicely. See slides 36 through 45 for an example of SAS code with a very clear PowerPoint animation of how this all works. It is true that SAS programmers can work with arrays, but this is actually a computational sleight of hand. Arrays are actually special columns in a data set.
R programmers are used to an interactive computational experience. Within a session, at any point in time the objects that resulted from a previous computation are available as inputs to the next calculation. There is always a sense of moving forward. If you didn’t compute something as part of the last function you ran, just write another function and compute it now. In SAS, however, one uses the various PROCS to conjure the results in a methodical, premeditated way. For example, something like the following code would run a simple regression in SAS sending the results to the console.
proc reg data = myData;
model Y = X;
run: 
However, if you wanted to have the fitted values and residuals available for a further computation, you would have to rerun the regression specifying an output file and the keywords for computing the fitted values and residuals.
proc reg DATA = myData;
MODEL Y = X / stb clb;
OUTPUT OUT=OUTREG P=PREDCIT R=RESED;
run;
Kathy Welch a statistical consultant at the University of Michigan, provides a very clear example of this linear way of working.
Most SAS programming probably gets done by writing SAS macros. Look at Bob Muenchen’s book (or this article) for practical examples of R functions to replace SAS macros. For more advanced work,the SAS/Tool Kit (yet another add on) allows SAS probrammers to write custom procedures. But, from a R programmer’s perspective probably the most exciting SAS product is the IML System which provides the ability to call R from within an IML procedure. The documentation  provides an example of transferring data stored in SAS/IML vectors to R, running a model in R and then, importing the results back into SAS/IML vectors.
Actually, if you are an R programmer, all you might really want to do is import data from SAS to R. Thre are at least five ways to do this using functions from various open source R libraries. (Note that some of these methods require preparation steps to be done in SAS.) The document “An Introduction to S and The Hmisc and Design Libraries” on CRAN is also helpful. However, I recommend using rxImport feature in RevoScaleR package that ships withRevolution R Enterprise.
Importing a SAS file with rxImport looks like this:
rxImport(inData=data,outFile="sasFileName")
Not only is it a one step process that does not require having SAS installed on your system, but it reads .sas7bdat files directly into Revolution Analytics' .xdf file format. You can easily work with SAS files that are too large to fit into memory Once in .xdf file format the data can be worked on with RevoScaleR’s parallel external memory algorithms (PEMAs) or written to .csv files or data frames.

No comments:

Post a Comment