Calling R Functions from SAS, OPTION=RLANG; PROC IML

#1
I need to run R code in SAS (OPTION=RLANG, PROC IML)

PROBLEM
So far I've been running Shapley regression in R using the following code

require(relaimpo)
data <- read.csv("H:/…/data/shapley data.csv")
reg <- lm(Q5 ~Q7_1+Q7_2+Q7_3+Q7_4+Q7_5+Q7_6+Q7_7, data=data)

summary(reg)
shap <- calc.relimp(reg)
shap
shap <- calc.relimp(reg, rela=TRUE)
shap

I want to be able to runthe above code in SAS (RLANG option; PROC IML) mainly because I can’t find the way to save the Shapley results (from R) in xls or csv file (lmg matrices, R2 etc) Objects from package relaimpo have classes relimplm (output from calc.relimp, the ones I’m interested in). For relimplm class there are methods for plotting and printing (S3 method) in R console window but I would like to be able to export these to xls. or csv. Of course I could just copy-paste but this is not very effective way of working. Sometimes I have multiple models to run and I need a bit of code that enables me to export the results. I’ve been trying different approaches but no success.

I think PROC IML in SAS will do the trick. The problem is that I can’t get it working. When I submit the following in SAS
PROC OPTIONS OPTION=RLANG;
RUN;

I get
ERROR: Unrecognized SAS option name, RLANG. - SAS 9.2
NORLANG Do not support access to R language interfaces - SAS 9.3

I’ve been trying different things incl. modification of configuration file (adding -RLANG) but it didn’t work.

Any thoughts? How can I make it work? Can you help please?


Thanks,
Edyta
 

Dason

Ambassador to the humans
#2
I can't help you with the SAS but I'm positive that we could get your output in the format you want if you want to stay in R.
 
#3
I can't help you with the SAS but I'm positive that we could get your output in the format you want if you want to stay in R.
Getting output from R to .xls or .csv would definitely help! Thanks.
As I said I'm not R expert (I use SAS as primary software) and I couldnt export lmg matrices.
I would really appreciate if you could help.

thanks
 
#4