View source: R/generate_sas_readfile.R
generate_sas_readfile | R Documentation |
Generates .csv and .sas files from a data.table
generate_sas_readfile(
data,
filename_stub,
shortener = function(x) {
substr(x, 1, 30)
}
)
sasify(
data,
filename_stub,
shortener = function(x) {
substr(x, 1, 30)
}
)
shorten_no_vowels(x)
data |
A data.table object |
filename_stub |
A character string which will be the filename of the generated files, eg, |
shortener |
A function which shortens variable names if longer than 30 characters |
The function generates 3 files:
filename_stub.csv
filename_stub.sas
filename_stub-variable-listing.csv
The variable listing provides details on variable names, type, length, and the original variable name (unabridged_name) if
the variable name was changed to comply with variable name character count restrictions, or
non alpha-numeric characters were removed from the variable name.
shorten_no_vowels
is a custom shortener which removes vowels prior to selecting the first 30 characters
iris_dt <- as.data.table(iris)
generate_sas_readfile(iris_dt, "iris")
# Long variable names
# Default shortener simply cuts the variable name at 30 characters
iris_dt$very_long_variable_name_that_exceeds_character_count_restrictions <- 1
generate_sas_readfile(iris_dt, "iris2")
# Custom shortener
shorten <- function(x){
y <- gsub("a|e|i|o|u","",x)
substr(y,1,30)
}
generate_sas_readfile(iris_dt, "iris3", shortener = shorten)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.