Skip to contents

Converts table from current SAS session into a R data.frame.

Usage

sas_to_r(table_name, libref = "WORK")

Arguments

table_name

string; Name of table in SAS.

libref

string; Name of libref SAS table is stored within.

Value

data.frame of the specified SAS table.

Details

SAS only has two data types (numeric and character). Data types are converted as follows:

  • numeric -> double

  • character -> character

  • numeric (datetime) -> POSIXct

  • numeric (date) -> POSIXct

In the conversion process dates and datetimes are converted to local time. If utilizing another timezone, use as.POSIXct() or lubridate::with_tz() to convert back to the desired time zone.

Examples

if (FALSE) { # \dontrun{
sas_connect()
cars <- sas_to_r("cars", "sashelp")
} # }