Since 2008, SAS has supported an interface for calling R from the SAS/IML matrix language.
A few years in the past, I wrote weblog posts
that describe name R from PROC IML.
For SAS 9.4, the method of putting in R and calling R from PROC IML is documented within the SAS/IML Consumer’s Information.
Basically, you put in R on the identical laptop that runs the SAS Workspace Server in order that SAS and R can
talk with one another. A SAS programmer can set up R on his desktop machine that runs SAS; a SAS administrator can set up R on a distant SAS Workspace Server.
Quick ahead to 2023. Immediately, many SAS clients run SAS Viya within the cloud.
If you wish to name R from PROC IML in SAS Viya,
R have to be put in and deployed by a SAS Viya administrator. The steps
to put in R and deploy SAS are very totally different from the outdated SAS 9 days.
This text offers a high-level overview.
Name SAS from R or name R from SAS?
In SAS 9.4, you’ll be able to name R from SAS.
In SAS Viya, you’ll be able to name SAS actions from open-source languages,
which suggests which you could additionally name SAS from R.
This functionality has been accessible since circa 2019 and can be utilized on Viya 3.5 in addition to fashionable releases of Viya.
Thus, R programmers have a selection. Do you need to use R as a consumer to drive the circulate of this system and infrequently name some computation in SAS? Or do you need to use SAS as a consumer and infrequently name computations in R?
SAS helps each choices.
Name SAS from R
If you’re primarily an R programmer who needs to name a Viya motion for a particular computation (perhaps an enormous parallel computation within the cloud), you need to use the SWAT bundle in R to connect with a CAS server and to name actions.
SWAT stands for SAS Wrapper for Analytics Switch, and SAS offers SWAT packages for a number of open-source languages, together with R and Python. The next two assets might help you get began with calling CAS actions from the R language:
Name R from SAS
As talked about earlier, the method of calling R from SAS is comparatively easy in SAS 9.4.
It’s extra complicated in SAS Viya as a result of each SAS and R should run “within the cloud.” In follow, because of this SAS and R needs to be in the identical container that’s deployed. Thus, a SAS Viya administrator should construct R, add it to a container,
and deploy the container to the cloud.
The primary steps are as follows. They’re taken from
Scott McCauley’s article, the place you will discover the main points:
This course of assumes that you have already got an
present SAS Viya deployment, and also you need to add R to the deployment.
- Construct R and packages: SAS offers a utility utility known as the “SAS Configurator for Open Supply,” which automates downloading, constructing, and putting in R from supply. The software builds R and any packages from supply on Linux. It places the compiled recordsdata in a location, known as the Persistent Quantity Declare (PVC). Observe: Scott’s instance installs each Python and R. In his instance, the
SAS Configurator for Open Supply creates and executes a job known as sas-pyconfig that (regardless of its identify) installs each open-source merchandise. He doesn’t present an instance that installs solely R. -
Configure SAS Viya to make use of the set up: Scott calls this “make R seen to SAS Viya.” -
Inform SAS Viya how to connect with R: You could outline some surroundings variables and SAS to allow R to be known as by PROC IML or by different SAS merchandise. This step is comparable in SAS 9.4, however in SAS Viya the adjustments have to be made to a YAML file. -
Optionally configure entry: You possibly can restrict who can entry exterior languages resembling R. -
Rebuild the SAS deployment and apply the adjustments: To use these adjustments, it’s essential to replace your SAS Viya deployment.
The aim of this text is to tell folks that
SAS offers instruments to incorporate R as a part of a SAS Viya deployment. These steps had been examined on
the Viya launch Secure 2022.12.
I’m not a SAS Viya administrator, so I confess that I’ve by no means carried out this course of myself.
If in case you have questions on this course of, please submit them to
Scott McCauley’s article. He’s way more certified than I’m to reply questions on configuration and deployment.