BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KAZ
Obsidian | Level 7 KAZ
Obsidian | Level 7

I am attempting to run R from proc iml and am getting the following error:

 

ERROR: An installed version of R could not be found.

 

I am running:

 

R 3.2.3 64bit

SAS 9.4 (TS1M2)

SAS/IML 13.2

 

on Windows x64 7pro.

 

From everythign I've read, IML 13.2 is compatible with R 3.2.x.  Is SAS relying on a system path variable or something else that I am missing?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

If R is installed in a nonstandard location (or if you have multiple copies of R and you want SAS to use a particular version), you can define the R_HOME environment variable. How you do that depends on the version of Windows that you are running, but hopefully this Windows 7 example will point you in the right direction.

 

From Control Panel, search for "environment." Click on the link that says something like "Edit environment variables for your account". (On Windows 7, it is on the System Properties dialog, on the Advanced Tab, click Environment Variables.)

Region Capture.png

 

Click New in the top section for "user variables."  Type R_HOME for the Variable name field and the full path of your R installation for the Variable value field.

 

Window Capture.png

 

View solution in original post

9 REPLIES 9
Rick_SAS
SAS Super FREQ

How are you calling PROC IML? From EG? The SAS Windowing environment (DMS)? Other?

 

R should be installed on the same computer that is executing SAS. So, for example, if you are running SAS through EG and connecting to a remote SAS server, then R needs to be installed on that server. If you install it on your local (client) PC, the SAS server will not be able to locate R.

 

KAZ
Obsidian | Level 7 KAZ
Obsidian | Level 7

Everything, SAS and R, is running on my Windows machine.

 

My sasv9.cfg file in SASHome\SASFoundation\9.4 directoy reads:

 

-RLANG
-config "C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg"

 

But when I run:

proc options option=RLANG;  run;

 

The NORLANG options is reported.

 

Rick_SAS
SAS Super FREQ

I'm confused. What has changed? This is a different error than you originally reported. The original problem seemed to say "you have permission to call R, but SAS can't find it."  Now you are telling us that you don't have permission to run R.

 

At any rate, I have had good sucess with putting -RLANG and -MEMSIZE 12GB in my

"C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg" file.

 

You have not told us how you are calling SAS.  The three common options are Enterprise Guide (EG), SAS Studio (web based), or native SAS Windowing environment (DMS).

 

KAZ
Obsidian | Level 7 KAZ
Obsidian | Level 7

I am running the native SAS windowing environment (DMS).

 

Nothing has changed.  The follwoing code:

 

proc options option=RLANG; run;

 

returns NORLANG in the log.  If I try to run R from proc IML such as :

 

proc iml;
submit / R;
  rx <- matrix( 1:3, nrow=1)             # vector of sequence 1,2,3
  rm <- matrix( 1:9, nrow=3, byrow=TRUE) # 3 x 3 matrix
  rq <- rm %*% t(rx)                     # matrix multiplication
  print(rq)
endsubmit;
run;
quit;

 

I get the following error:

 

ERROR: The RLANG system option must be specified in the SAS
       configuration file or on the SAS invocation command line to
       enable the submission of R language statements.

Rick_SAS
SAS Super FREQ

Great. I'm just saying that you are now getting a different error than you originally stated. 

 

Add -RLANG to your sasv9.cfg file. Exit SAS.

 

Re-run SAS and try

proc options option=RLANG value;

run;

 

The VALUE option should tell you that RLANG was set in your config file. If it doesn't, you might need to ask a system administrator whether there are other config files that run after yours. 

 

Alternatively, click RMB on the SAS icon on your desktop of Start menu. Select "Properties" and add -RLANG to the Target command line in the "Properties" dialog box.  Maybe the command line has -NORLANG specified, which would override the option.

KAZ
Obsidian | Level 7 KAZ
Obsidian | Level 7

Thanks.  I aplogize for the confusion. 

 

In my start menu, the target for the SAS icon was:

"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -CONFIG "C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg"

 

and I added the -RLANG option in the prior config file.  I launched SAS with:

"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -CONFIG "C:\Program Files\SASHome\SASFoundation\9.4\sasv9.cfg"

 

And now the RLANG option is regonized:

 

proc options option=RLANG value; run;
Option Value Information For SAS Option RLANG
    Value: RLANG
    Scope: SAS Session
    How option value set: Config File
    Config file name:
            C:\Program Files\SASHome\SASFoundation\9.4\sasv9.cfg

 

Now I received the original error message when I try to call R:

 

2
3    proc iml;
NOTE: Writing HTML Body file: sashtml.htm
NOTE: IML Ready
4    submit / R;
5      rx <- matrix( 1:3, nrow=1)             # vector of sequence 1,2,3
6      rm <- matrix( 1:9, nrow=3, byrow=TRUE) # 3 x 3 matrix
7      rq <- rm %*% t(rx)                     # matrix multiplication
8      print(rq)
9    endsubmit;
ERROR: SAS could not initialize the R language interface.

 statement : SUBMIT at line 4 column 1
10   run;
NOTE: Module MAIN is undefined in IML; cannot be RUN.
11   quit;
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
      real time           2.06 seconds
      cpu time            0.46 seconds


ERROR: An installed version of R could not be found.

 

Rick_SAS
SAS Super FREQ

What is the location in which you have installed R?  For example, my version of R is installed in

C:\Program Files\R\R-3.2.2

KAZ
Obsidian | Level 7 KAZ
Obsidian | Level 7

Ah, now we are getting somewhere.

 

I just noticed R is installed in my My Documents directory. 

 

How do I tell SAS to look for it there?

Rick_SAS
SAS Super FREQ

If R is installed in a nonstandard location (or if you have multiple copies of R and you want SAS to use a particular version), you can define the R_HOME environment variable. How you do that depends on the version of Windows that you are running, but hopefully this Windows 7 example will point you in the right direction.

 

From Control Panel, search for "environment." Click on the link that says something like "Edit environment variables for your account". (On Windows 7, it is on the System Properties dialog, on the Advanced Tab, click Environment Variables.)

Region Capture.png

 

Click New in the top section for "user variables."  Type R_HOME for the Variable name field and the full path of your R installation for the Variable value field.

 

Window Capture.png

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 9 replies
  • 4238 views
  • 1 like
  • 2 in conversation