Transfer from an R Source to a SAS Destination

You can transfer data and results from R data frames or matrices to a SAS data set, a DataObject, or a SAS/IML matrix. The following table summarizes the frequently used methods that copy from an R source to a SAS destination.

Table 11.2 Transferring from an R Source to a SAS Destination

Method or Module

R Source

SAS Destination

DataObject.AddVarFromR

R expression

DataObject variable

DataObject.CreateFromR

R expression

DataObject

ImportDataSetFromR

R expression

SAS data set

ImportMatrixFromR

R expression

SAS/IML matrix

The next section includes an example of calling an R analysis. Some of the results from the analysis are then transferred into SAS/IML matrices and into variables in a DataObject.

The result of an R analysis can be a complicated structure. In order to transfer an R object via the previously mentioned methods and modules, the object must be coercible to a data frame. (The R object m can be coerced to a data frame provided that the function as.data.frame(m) succeeds.) There are many data structures that can not be coerced into data frames. As the example in the next section shows, you can use R statements to extract simpler objects and transfer the simpler objects.