|
刚安装R-2.15.3版本,在SAS9.3_win32平台测试成功!!
运行如下程序:
-------------------------------------------------------------------------------
/* R测试 */
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;
quit;
------------------------------------------------------------------------------
运行结果:
====================================
1 /* R测试 */
2 proc options option=RLANG;
3 run;
SAS (R) PROPRIETARY SOFTWARE RELEASE 9.3 TS1M2
RLANG 支持访问 R 语言接口
NOTE: “PROCEDURE OPTIONS”所用时间(总处理时间):
实际时间 0.00 秒
CPU 时间 0.00 秒
4
5 proc iml;
NOTE: 正在写入 HTML Body(主体)文件: sashtml.htm
NOTE: IML Ready
6 /* Comparison of matrix operations in IML and R */
7 print "---------- SAS/IML Results -----------------";
8 x = 1:3;
8 ! /* vector of sequence 1,2,3 */
9 m = {1 2 3, 4 5 6, 7 8 9};
9 ! /* 3 x 3 matrix */
10 q = m * t(x);
10 ! /* matrix multiplication */
11 print q;
12
13 print "------------- R Results --------------------";
14 submit / R;
15 rx <- matrix( 1:3, nrow=1) # vector of sequence 1,2,3
16 rm <- matrix( 1:9, nrow=3, byrow=TRUE) # 3 x 3 matrix
17 rq <- rm %*% t(rx) # matrix multiplication
18 print(rq)
19 endsubmit;
20 quit;
NOTE: Exiting IML.
NOTE: “PROCEDURE IML”所用时间(总处理时间):
实际时间 0.64 秒
CPU 时间 0.17 秒
---------- SAS/IML Results -----------------
q
14
32
50
------------- R Results --------------------
[,1]
[1,] 14
[2,] 32
[3,] 50
========================================
测试成功,OK!!
而且,打开 SAS IML Studio 12.1,打开运行 Program\Doc\StatGudie\R文档,成功!!
|