The RLANG
option
At the time that SAS is started, you can enable an option called RLANG
which allows R to be called from within SAS. Enabling this option doesn’t require admin privileges, and it allows you to pass data back and forth between the two languages fairly easily, making it quite a bit more useful than the SASmarkdown
package.
The RLANG
option is a SAS concept which has absolutely no relation to the rlang
package in R.
Once RLANG
is enabled, you can run R code from within proc iml
. To execute R code, use a SUBMIT
statement with the R option. Anything that goes between the SUBMIT
and ENDSUBMIT
lines will be evaluated as R code rather than as SAS code.
proc iml;
SUBMIT / R;
# Your R code goes here
ENDSUBMIT;
run;
Moving data back and forth between the two languages is fairly is easy. In SAS, you can use the following:
*Move data from R to SAS;
ImportDataSetFromR("sas_data_name", "r_df_name")
*Move data from SAS to R;
ExportDataSetToR("sas_data_name", "r_df_name")
Although the RLANG
option doesn’t require admin privileges if you’re using base SAS, it does require admin privileges if you’re using SAS Enterprise Guide. The video below provides instructions on how to enable this option within SAS EG.