ImportDataSetFromR

Prototype

void ImportDataSetFromR( String sLibrefDotDataSetName, String sRExpr )

Parameters

String sLibrefDotDataSetName
A string of the form "libref.member" that specifies the SAS data set to create. You do not need to specify the libref if it is WORK.

String sRExpr
An R expression that is evaluated and then coerced to a data frame.

Remarks

This module creates a SAS data set from the result of evaluating an R expression. The module evaluates the R expression, coerces the result to an R data frame, and creates a SAS data set from the variables of the R data frame.

The names of the variables in the data set are derived from the names of the variables in the R data frame. Because SAS has different variable naming rules from R, IMLPlus applies the following transformations to convert an R variable name to a valid SAS variable name:

  1. If the name is longer than 32 characters, it is truncated to 32 characters.
  2. If the first character is not valid for a SAS variable name, the character is replaced with '_'. A SAS variable name must begin with one of the following characters: 'A'-'Z', 'a'-'z', or '_'.
  3. If any of the remaining characters are not valid for a SAS variable name, they are replaced with '_'. A SAS variable name can only contain the following characters: 'A'-'Z', 'a'-'z', '0'-'9', or '_'.
  4. If the resulting name duplicates an existing name, a number is appended to the name to make it unique. If appending the number causes the length of the name to exceed 32 characters, the name is truncated to make room for the number.

For information about how IML Studio transfers data from R to IMLPlus, please refer to the topic Data Exchange Details.

IMPORTANT: This module imports data from client-side R. You must use the RUN statement to invoke this module because there is a corresponding built-in IML subroutine of the same name that imports data from server-side R.
Example
submit / R;
df <- trees
endsubmit;

run ImportDataSetFromR( "WORK.trees", "df" );

submit;
proc print data=trees;
run;
endsubmit;
See Also

DataObject.CreateFromR