Previous Page | Next Page

Language Reference

EXPORTDATASETTOR Call

CALL EXPORTDATASETTOR( SASDataSet, RDataFrame ) ;

You can use the EXPORTDATASETTOR subroutine to transfer data from a SAS data set to an R data frame. It is easier to read the subroutine name when it is written in mixed case: ExportDataSetToR.

The arguments to the subroutine are as follows:

SASDataSet

is a literal string or a character matrix that specifies the two-level name of a SAS data set (for example, Sashelp.Class).

RDataFrame

is a literal string or a character matrix that specifies the name of an R data frame.

You can call the subroutine provided that the following statements are true:

  1. The R statistical software is installed on the SAS workspace server.

  2. The SAS system administrator at your site has enabled the RLANG SAS system option. (See The RLANG System Option.)

The following statements copy data from the Sashelp.Class data set into an R data frame called class:

proc iml;
run ExportDataSetToR("Sashelp.Class", "class");

submit / R;
names( class )
endsubmit;

To demonstrate that the data were successfully transferred, the names function in the R language is used to print the names of the variables in the R data frame. The output is shown in Figure 23.100.

Figure 23.100 Output from R
[1] "Name" "Sex" "Age" "Height" "Weight"

You can transfer data from an R data frame into a SAS data set by using the IMPORTDATASETFROMR call. See Chapter 11, Calling Functions in the R Language, for details about transferring data between R and SAS software.

Previous Page | Next Page | Top of Page