Useful to extract factor formatting information contained in a proc format SAS statement.
Usage
parse_formats(
path_to_format_definition,
ignore_keywords = c("value"),
encoding = "ISO-8859-1"
)
Arguments
- path_to_format_definition
(string) Path to the text file to be parsed
- ignore_keywords
A vector of keywords to be ignored when searching for the name of the variable to be formatted
- encoding
Encoding for the text file
Examples
tmpfile <- tempfile()
write( "proc format;
value yn 1=\"yes\"
0=\"no\";
value sex 1=\"female\"
0=\"male\";
run;",tmpfile)
parse_formats(tmpfile)
#> Warning: The algorithm to extract SAS comments in this function is not implemented well.
#> This function works best if you manually remove all comments from the
#> text file and make sure there are no labels containing strings of the form '/*' or '*/'.
#> $yn
#> $yn$levels
#> [1] 1 0
#>
#> $yn$labels
#> [1] "yes" "no"
#>
#>
#> $sex
#> $sex$levels
#> [1] 1 0
#>
#> $sex$labels
#> [1] "female" "male"
#>
#>