If you have a modern version of SAS and an up-to-date version of R on Windows, you are mostly likely to be able to run R code inside SAS. All you need to do for the setup is in the following two steps:
First, tell SAS to launch with the R functionality turned on. You can achieve this by either:
- a) add
-RLANG
to the SAS command line, or - b) add
-RLANG
to the end of the SAS config file (sasv9.cfg).
Second, tell SAS where to find R. You can achieve this by either:
- a) add
options set=R_HOME='C:\Program Files\R\R-3.6.2';
to your autoexec.sas, or - b) add
-SET R_HOME "C:\Program Files\R\R-3.6.2"
to the end of the SAS config file (sasv9.cfg).
Please change the R path according to the R version installed on your machine.
Now, you can run proc options option=RLANG; run;
to check whether the R functionality has been turned on in SAS.
In summary, if you prefer not to change the SAS config file (sasv9.cfg), you only need to do the following two things:
- add
-RLANG
to the SAS command line, - add the following two lines to your autoexec.sas:
options set=R_HOME='C:\Program Files\R\R-3.6.2';
. Please change the R path according to the R version installed on your machine.proc options option=RLANG; run;
. So that you can always see whether SAS is ready to run R when SAS is launched.
One thought on “Setup SAS to Run R Code inside SAS”