Using R to Analyze Data in a SAS Data Set |
As an alternative to the data transfer statements in the previous section, you can call the ExportDataSetToR subroutine to transfer the entire SAS data set to an R data frame. For example, you could use the following statements to create an R data frame named Class and to model the Weight variable:
call ExportDataSetToR("Sashelp.Class", "Class"); submit / R; Model <- lm(Weight ~ Height, data=Class, na.action="na.exclude") endsubmit;
The R language is case-sensitive so you must use the correct case to refer to variables in a data frame. You can use the CONTENTS function in the SAS/IML language to obtain the names and capitalization of variables in a SAS data set.