Hi all,
I am using both SAS and R for my tasks. For a particular task, I use SAS for data manipulation, export, then import into R, and then use R to fit a Bayesian model with package rstan. For another task, I use R for data manipulation, export, then import into SAS.
I have known that we can call R into SAS by using proc iml. However, I think Rstudio is also strong as we can check values quickly so for me working with R in SAS is not much advantageous as working with R in Rstudio.
From your experience, could you suggest in which situations should we call R into SAS with proc iml rather than working independently as I mention above?
Thank you for reading!
Kind regards,
Trung Dung.
While I agree with my friend @andreas_lds that there is a cost to switch contexts (more moving parts, more apps to maintain, harder to automate), I know many SAS customers that use SAS alongside other tools like Python and R -- often across different teams -- so a smooth integration process is required.
This video featuring @Rick_SAS explains one big advantage: Reuse. That is, sometimes we have colleagues that build good work in R -- and we don't want to have to re-implement in SAS to take advantage of it.
SAS Viya supports access from R into SAS. @joeFurbee shares an example using RStudio in this blog.
If you want to make full use of the SAS environment (metadata, batch processing, ...), calling R from within SAS is mandated.
Data engineering (or what's called ETL) is a pure SAS domain. R is lacking considerably with respect to that, at least it was when I last looked into it.
I have hardly any experience in R and i really don't mean to be rude, but i can't think of a polite way to say: any process that requires switching tools is crap and needs redesign, if the process could be implemented by using just one tool.
While I agree with my friend @andreas_lds that there is a cost to switch contexts (more moving parts, more apps to maintain, harder to automate), I know many SAS customers that use SAS alongside other tools like Python and R -- often across different teams -- so a smooth integration process is required.
This video featuring @Rick_SAS explains one big advantage: Reuse. That is, sometimes we have colleagues that build good work in R -- and we don't want to have to re-implement in SAS to take advantage of it.
SAS Viya supports access from R into SAS. @joeFurbee shares an example using RStudio in this blog.
As others have mentioned, the workflow is important. I have written about 12 advantages of using the SAS/IML interface to call R, and most involve the convenience of integrating the two programs.
My suggestion: First use RStudio or whatever R tools you want to develop the R portion of your analysis, using simulated data if necessary while you write the program. (Do the same for the SAS portion of your program, using your favorite SAS development tools.) After the R program is debugged and stable, integrate it into your SAS workflow. Many people try to develop the SAS and R portions of the code simultaneously, and that usually leads to problems. If you adopt a modular approach to development and debugging, the process will go smoother.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.