Package 'readsas'

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

Help Index


helper function to convert SAS date numeric to date

Description

helper function to convert SAS date numeric to date

Usage

convert_to_date(x)

convert_to_datetime(x)

convert_to_time(x)

Arguments

x

date or datetime variable

Examples

# 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

Description

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().

Usage

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
)

Arguments

file

file to read

debug

print debug information

convert_dates

default is TRUE

recode

default is TRUE

select.rows

integer. Vector of rows to import. Minimum 0. Rows imported are sorted. If 0 is in select.rows, zero rows are returned.

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 "" to NA_character_ when importing.

See Also

read.xport

Examples

fl <- system.file("extdata", "cars.sas7bdat", package = "readsas")
read.sas(fl)