readSSOCS | R Documentation |
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.
readSSOCS(sasDataFiles, years, forceReread = FALSE, verbose = TRUE)
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 |
years |
an integer vector of the year associated with the index position of the |
forceReread |
a logical value to force rereading of all processed data.
The default value of |
verbose |
a logical value to either print or suppress status message output.
The default value is |
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.
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.
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.
Tom Fink
downloadSSOCS
, and getData
## Not run:
#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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.