Language Reference
IMPORTTABLEFROMR Function
IMPORTTABLEFROMR (RExpr) ;
This function is supported only by the IML procedure.
You can use the IMPORTTABLEFROMR function to transfer data from an R data frame to a SAS/IML table. It is easier to read the function name when it is written in mixed case: ImportTableFromR.
The argument for the function follows:
- RExpr
is a literal string or a character matrix that specifies the name of an R data frame or, in general, an R expression that can be coerced to an R data frame.
The following statements create a data frame in R named RData and copy the data into the SAS/IML table named tbl.
proc iml;
submit / R;
z = c('a','b','c','d','e')
RData <- data.frame(x=1:5, y=(1:5)^2, z=z)
endsubmit;
tbl = ImportTableFromR("RData");
call TablePrint(tbl);
Figure 192: Contents of a SAS Data Set Created from R Data
| tbl | |||
|---|---|---|---|
| Obs | X | Y | Z |
| 1 | 1 | 1 | a |
| 2 | 2 | 4 | b |
| 3 | 3 | 9 | c |
| 4 | 4 | 16 | d |
| 5 | 5 | 25 | e |
For more information about transferring data between R data frames and SAS/IML tables, see the ImportDataSetFromR subroutine.