Statistical programming, matrix languages, and more

R Interface on Linux

Reply
N/A
Posts: 0

R Interface on Linux

I was disappointed to find out that IML 9.22 on Linux does not support the R interface. (Right?) The announcement for IML 9.22 at http://support.sas.com/rnd/app/AnalyticalProducts922.html doesn't mention this limitation

and the overview page in the IML 9.22 documentation says

SAS/IML 9.22 includes two new features and many new functions and subroutines. The following features are new:

...
the ability to call functions and packages in the R statistical programming language from within the IML procedure. You can use new SAS/IML subroutines to transfer data between SAS data formats and R data formats.

and it wasn't until we installed IML 9.22 that we discovered the problem.
The limitation to Windows is mentioned at the bottom of
http://support.sas.com/documentation/cdl/en/imlug/63541/HTML/default/viewer.htm#imlug_r_sect003.htm

When can we expect an IML/R interface for IML on Linux?

Rob
SAS Employee
Posts: 94

Re: R Interface on Linux

IML 9.22 should support the R interface on Linux, for R version 9.22 or later. Have you tried it and found a problem, or are you just going by the doc?
N/A
Posts: 0

Re: R Interface on Linux

RIck,

Thanks for the reply, good news that the SAS/R interface should work.

I did try an example of calling R that failed, so both that failure and the documentation suggesting only Windows worked led to my post.

We do have R 2.10 installed, but did not follow the instructions in the PDF about compiling to enable an R shared library or setting the R_HOME environment variable. We will try that and post the results (presumably successful)

Rob
N/A
Posts: 0

Re: R Interface on Linux

Here is an update, still unsuccessful.

We contacted technical support, but have so far received no helpful suggestions.
We do have SAS maintenance release 3 with IML 9.22

I followed the PDF document on how to install R. Here is what I sent to tech support.
Note the error
ERROR: Could not find extension: (tkintr)

There are no files in our SAS installation with any name like that
-----------------------------------------------------------------------------
From: Robert H Creecy/CSRM/HQ/BOC
To: John Wesley McCue/SSD/HQ/BOC@BOC
Cc: Chad Eric Russell/SRD/HQ/BOC@BOC, Kyle A Johnson/SSD/HQ/BOC@BOC, Raymond Illian/CSVD/HQ/BOC@BOC
Date: 01/05/2011 10:32 AM
Subject: Re: Fw: update of IML on research2-1 not working


John,

So I queried the SAS IML forum at http://support.sas.com/forums/thread.jspa?messageID=48202 and found out SAS/IML 9.22 on Linux should support
the R interface after all. The document at http://support.sas.com/documentation/installcenter/en/iktkintrii/64028/PDF/default/install.pdf
(also attached) mentions how R should be installed and the user environment set up to enable the SAS/R interface.

There are three main technical points that need to be followed

1. R should be compiled and installed using the ./configure --enable-R-shlib
to create a shared object library.
2. The R_HOME environment variable should point to the root of the R installation, for 64 bit Linux default is /usr/lib64/R
3. R should be version 2.9.1 or later

We have two versions of R installed on research2-1, R-2.9.0 which is the default CSvD build installed in /usr/lib64/R
and R-2.11.0 installed in /apps/R/R-2.11.0/lib64/R

Both versions were compiled using the --enable-R-shlib, as reflected by an existing libR.so
(I compiled the R-2.11.0 version myself)

[creec003@research2-1 R]$ pwd
/apps/R/R-2.11.0/lib64/R
[creec003@research2-1 R]$ ls -l lib
total 12020
-rwxrwxr-x 1 creec003 srd-admin 18225 Apr 30 2010 libRblas.so
-rwxrwxr-x 1 creec003 srd-admin 2990923 Apr 30 2010 libRlapack.so
-rwxrwxr-x 1 creec003 srd-admin 9237971 Aug 12 13:53 libR.so
[creec003@research2-1 R]$
[creec003@research2-1 R]$ pwd
/usr/lib64/R
[creec003@research2-1 R]$ ls -l lib
total 12900
-rwxr-xr-x 1 root root 427786 Apr 17 2009 libRblas.so
-rwxr-xr-x 1 root root 3555235 Apr 17 2009 libRlapack.so
-rwxr-xr-x 1 root root 9184834 Apr 17 2009 libR.so

Here is the test SAS/IML program that fails trying to use R-2.11.0 and the files are attached

[creec003@research2-1 mysas]$ export R_HOME=/apps/R/R-2.11.0/lib64/R
[creec003@research2-1 mysas]$ cat imlcallR.sas
proc options option=RLANG;
run;
proc iml;
/* Comparison of matrix operations in IML and R */
print "---------- SAS/IML Results -----------------";
x = 1:3; /* vector of sequence 1,2,3 */
m = {1 2 3, 4 5 6, 7 8 9}; /* 3 x 3 matrix */
q = m * t(x); /* matrix multiplication */
print q;


print "------------- R Results --------------------";
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;
[creec003@research2-1 mysas]$ sas -rlang imlcallR.sas
[creec003@research2-1 mysas]$ cat imlcallR.log
1 The SAS System 10:28 Wednesday, January 5, 2011

NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.2 (TS2M3)
Licensed to CENSUS BUREAU FOUNDATION LINA, Site 70070007.
NOTE: This session is executing on the Linux 2.6.18-194.26.1.el5 (LIN X64) platform.



You are running SAS 9. Some SAS 8 files will be automatically converted
by the V9 engine; others are incompatible. Please see
http://support.sas.com/rnd/migration/planning/platform/64bit.html

PROC MIGRATE will preserve current SAS file attributes and is
recommended for converting all your SAS libraries from any
SAS 8 release to SAS 9. For details and examples, please see
http://support.sas.com/rnd/migration/index.html


This message is contained in the SAS news file, and is presented upon
initialization. Edit the file "news" in the "misc/base" directory to
display site-specific news and information in the program log.
The command line option "-nonews" will prevent this display.




NOTE: SAS initialization used:
real time 0.88 seconds
cpu time 0.02 seconds

1 proc options option=RLANG;
2 run;

SAS (r) Proprietary Software Release 9.2 TS2M3

RLANG Support access to R language interfaces
NOTE: PROCEDURE OPTIONS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


3 proc iml;
NOTE: IML Ready
4 /* Comparison of matrix operations in IML and R */
5 print "---------- SAS/IML Results -----------------";
6 x = 1:3;
6 ! /* vector of sequence 1,2,3 */
7 m = {1 2 3, 4 5 6, 7 8 9};
7 ! /* 3 x 3 matrix */
8 q = m * t(x);
8 ! /* matrix multiplication */
9 print q;
10
11
12 print "------------- R Results --------------------";
13 submit / R;
14 rx <- matrix( 1:3, nrow=1) # vector of sequence 1,2,3
15 rm <- matrix( 1:9, nrow=3, byrow=TRUE) # 3 x 3 matrix
16 rq <- rm %*% t(rx) # matrix multiplication

2 The SAS System 10:28 Wednesday, January 5, 2011

17 print(rq)
18 endsubmit;
ERROR: The R language interface is not available on this system.

statement : SUBMIT at line 13 column 5
19 run;
NOTE: Module MAIN is undefined in IML; cannot be RUN.
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: The PROCEDURE IML printed page 1.
NOTE: PROCEDURE IML used (Total process time):
real time 0.47 seconds
cpu time 0.02 seconds


ERROR: Could not find extension: (tkintr)
ERROR: Errors printed on page 2.

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 1.43 seconds
cpu time 0.06 seconds

[creec003@research2-1 mysas]$ cat imlcallR.lst
The SAS System 10:28 Wednesday, January 5, 2011 1

---------- SAS/IML Results -----------------


q

14
32
50


------------- R Results --------------------
[creec003@research2-1 mysas]$





From: John McCue
To: "'john.wesley.mccue@census.gov'" , "'robert.h.creecy@census.gov'"
Date: 01/06/2011 03:42 PM
Subject: Fw: [SAS 7610509911] Fw: update of IML on research2-1 not working



Hi Rob,

Did the suggestions from Rick or Joe solve the problem?
Q

----- Original Message -----
From: SAS Technical Support [mailto:support@sas.com]
Sent: Thursday, January 06, 2011 03:30 PM
To: John McCue
Subject: [SAS 7610509911] Fw: update of IML on research2-1 not working

::~:: NOTE: IF YOU REPLY, ALL TEXT FOLLOWING THIS LINE WILL BE IGNORED.


Hi John:

Please check back with the customer and ask them if the suggestions that Rick and Joe had for them worked or not.

Sincerely,
Rob Agnelli
Technical Support Statistician
SAS

NOTE: If you have any follow-up questions on this matter, please call or reply
to this email by January 13, 2011.
SAS Employee
Posts: 25

Re: R Interface on Linux

To add some closure to this issue, I thought I'd chime in.

Rob's problem was due to an installation issue. Though SAS/IML was at the correct level to support the interface to R, the necessary "TK Extensions" had not been installed (hence the missing file Rob mentioned.) After these were installed, the interface to R worked correctly.
SAS Employee
Posts: 94

Re: R Interface on Linux

Oops, R version 2.9 or later that is supported on Linux. If you have problems getting it to work, please contact TS
SAS Super FREQ
Posts: 3,615

Re: R Interface on Linux

Thanks for finding that omission in the doc. I have updated it to read:

The interface to R is supported on computers that run a 32-bit or 64-bit Windows operating system or Linux operating systems. If you are using SAS software in a 64-bit Linux environment, you must download a 64-bit binary distribution of R. Otherwise, download a 32-bit binary distribution.

The document "Installing R on Linux Operating Systems" is available on support.sas.comand includes pointers for installing R so that it works with the interface to R. The URL is
http://support.sas.com/documentation/installcenter/en/iktkintrii/64028/PDF/default/install.pdf
Ask a Question
Discussion stats
  • 6 replies
  • 1014 views
  • 0 likes
  • 4 in conversation