Title: | Importing SAS Files |
---|---|
Description: | Package to read the SAS file format. |
Authors: | Jan Marvin Garbuszus [aut, cre] |
Maintainer: | Jan Marvin Garbuszus <[email protected]> |
License: | GPL (>= 2) | file LICENSE |
Version: | 0.5 |
Built: | 2024-11-16 04:35:14 UTC |
Source: | https://github.com/JanMarvin/readsas |
helper function to convert SAS date numeric to date
convert_to_date(x) convert_to_datetime(x) convert_to_time(x)
convert_to_date(x) convert_to_datetime(x) convert_to_time(x)
x |
date or datetime variable |
# 2000-03-17 convert_to_date(14686) # 2012-11-10 03:49:19 convert_to_datetime(1668138559) # 04:04:46 convert_to_time(14686)
# 2000-03-17 convert_to_date(14686) # 2012-11-10 03:49:19 convert_to_datetime(1668138559) # 04:04:46 convert_to_time(14686)
read.sas
is a general function for reading sas7bdat files.
It supports a variety of complex sas7bdat files, x86 and x64, big and small
endian, and both compression types. It has been tested with numeric and
character data, and provides helper functions for converting sas7bdat to R
types Date
and POSIXct
. Time variables are converted to characters.
Conversion to date variables is applied if a known date, datetime or time
format is found in the sas7bdat file. For user-defined formats, the package
provides functions to convert from sas7bdat to R.
Input files may contain deleted rows that are marked as deleted instead of
being removed from the input data. These are removed on import, if you still
need them look at remove_deleted
. Formats, labels and additional file
information are available with attributes()
.
read.sas( file, debug = FALSE, convert_dates = TRUE, recode = TRUE, select.rows = NULL, select.cols = NULL, remove_deleted = TRUE, rownames = FALSE, empty_to_na = FALSE )
read.sas( file, debug = FALSE, convert_dates = TRUE, recode = TRUE, select.rows = NULL, select.cols = NULL, remove_deleted = TRUE, rownames = FALSE, empty_to_na = FALSE )
file |
file to read |
debug |
print debug information |
convert_dates |
default is |
recode |
default is |
select.rows |
integer. Vector of rows to import. Minimum 0. Rows
imported are sorted. If 0 is in |
select.cols |
character: Vector of variables to select. |
remove_deleted |
logical if deleted rows should be removed from data |
rownames |
first column will be used as rowname and removed from data |
empty_to_na |
logical. In SAS empty characters are missing. this option
allows to convert |
fl <- system.file("extdata", "cars.sas7bdat", package = "readsas") read.sas(fl)
fl <- system.file("extdata", "cars.sas7bdat", package = "readsas") read.sas(fl)