Language Reference


EXPORTDATASETTOR Call

CALL EXPORTDATASETTOR (SAS-data-set, 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:

SAS-data-set

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 section The RLANG System Option.)

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

proc iml;
call 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Ā 24.128.

Figure 24.128: 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.