Opens a connection to a School Survey on Crime and Safety (SSOCS) data file and
returns an edsurvey.data.frame, or an edsurvey.data.frame.list if multiple files specified,
with information about the file(s) and data.
Arguments
- sasDataFiles
a character vector to the full SAS (*.sas7bdat) data file path(s) you wish to read. If multiple paths are specified as a vector, it will return an
edsurvey.data.frame.list.- years
an integer vector of the year associated with the index position of the
sasDataFiledata file vector. The year is required to correctly determine required metadata about the file. Valid year values are as follows: 2000 (1999–2000), 2004 (2003–2004), 2006 (2005–2006), 2008 (2007–2008), 2010 (2009–2010), 2016 (2015–2016), 2018 (2017–2018).- forceReread
a logical value to force rereading of all processed data. The default value of
FALSEwill speed up thereadSSOCSfunction by using existing read-in data already processed.- verbose
a logical value to either print or suppress status message output. The default value is
TRUE.
Value
An edsurvey.data.frame if one data file is specified or an edsurvey.data.frame.list if multiple files are specified in the sasDataFiles parameter.
Details
Reads in the unzipped files downloaded from the SSOCS Data Products website in SAS format. Other sources of SSOCS data, such as restricted-use data or other websites, may require additional conversion steps to generate the required SAS format.
Note
For the readSSOCS function, value label information is stored and retrieved automatically within the EdSurvey package (based on the year parameter),
as the SAS files contain only raw data values.
See also
downloadSSOCS, and getData
Examples
if (FALSE) { # \dontrun{
#download SSOCS data for years 2016 and 2018
downloadSSOCS(years = c(2016, 2018))
rootPath <- "~/"# may need to change this
#get SAS *.sas7bdat file paths of all SSOCS files for 2016 and 2018
filesToImport <- list.files(path = file.path(rootPath, "SSOCS", c(2016, 2018)),
pattern="\\.sas7bdat$",
full.names = TRUE)
#import all files to edsurvey.data.frame.list object
esdfList <- readSSOCS(sasDataFiles = filesToImport,
years = c(2016, 2018),
forceReread = FALSE,
verbose = TRUE)
#reading in the 2018 to an edsurvey.data.frame object
esdf <- readSSOCS(sasDataFiles = file.path(rootPath, "SSOCS/2018/pu_ssocs18.sas7bdat"),
years = 2018,
forceReread = FALSE,
verbose = TRUE)
#search for variables in the edsurvey.data.frame containing the word 'bully'
searchSDF(string="bully", data=esdf)
} # }