Call R and Python from base SAS
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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:
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)
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.