import and print single sas file from folder in R

Viewed 31

I am try to read a single sas file from a folder in R

Folder name = Clinical ,

File name = top.sas7bdat

Also trying to print the metadata in the sasfile

1 Answers

The sas7bdat package can read a sas data set and metadata.

library(sas7bdat)
library(dplyr) # needed for the bind_rows function

# use read.sas7bdat to read the dataset into a data frame
sas_df <- read.sas7bdat('Clinical/top.sas7bdat')

print(sas_df)

# This data frame has an attribute column.info which is a list containing a list of
#  metadata items for each variable. You can extraxt it into a data frame using:
contents <- do.call(bind_rows, lapply(attr(sas_df,'column.info'),as.data.frame))

print(contents)

Related