Calling R Functions from PROC IML

The SUBMIT and ENDSUBMIT statements also provide an interface to the R statistical programming language, so that you can submit R statements from within your SAS/IML program. To submit statements to R, specify the R option in the SUBMIT statement.

You can transfer data from SAS/IML matrices and SAS data sets into R matrices and R data frames, and vice versa. Specifically, the following subroutines are available to transfer data from a SAS format into an R format:

Table 1.1 Transferring from a SAS Source to an R Destination

Subroutine

SAS Source

R Destination

ExportDataSetToR

SAS data set

R data frame

ExportMatrixToR

SAS/IML matrix

R matrix

In addition, the following subroutines are available to transfer data from an R format into a SAS format:

Table 1.2 Transferring from an R Source to a SAS Destination

Subroutine

R Source

SAS Destination

ImportDataSetFromR

R expression

SAS data set

ImportMatrixFromR

R expression

SAS/IML matrix

In Table 1.2, an "R expression" can be the name of a data frame, the name of a matrix, or an expression that results in either of these data structures.