Transfer from a SAS Source to an R Destination

The following table summarizes the frequently used methods that copy from a SAS source to an R destination. Several of these modules and methods are used in the program in the next section. For details of the transfer process and a full list of methods that transfer data, see the "Accessing R" chapter in the online Help.

Table 11.1 Transferring from a SAS Source to an R Destination

Method or Module

SAS Source

R Destination


SAS data set

R data frame


SAS/IML matrix

R matrix



R data frame

As a simple example, the following program transfers a data set from the Sashelp libref into an R data frame named df. The program then submits an R statement that displays the names of the variables in the data frame.

run ExportDataSetToR("Sashelp.Class", "df" );
submit / R;

The R names function produces the output shown in Figure 11.2.

Figure 11.2 Sending Data to R
[1] "Name"   "Sex"    "Age"    "Height" "Weight"