View source: R/parseScript_SPSS.R
parseScript_SPSS | R Documentation |
Parses an SPSS Syntax Script (.sps) file to return information relating to fixed-width data files.
parseScript_SPSS(
spsFilePath,
verbose = FALSE,
outputFormat = c("data.frame"),
encoding = getOption("encoding")
)
spsFilePath |
a character value of the file path to the SPSS script to parse. |
verbose |
a logic value to indicate if user wishes to print parsing activity to console. Default value is |
outputFormat |
a named argument to indicate which output format the resulting object should be. See details for information on each format.
Currently, |
encoding |
a character value to indicate the encoding specification that is used by |
NOT CURRENTLY EXPORTED! In Future this could potentially be made to a separate R package THIS parseScript_SPSS function should be used 100 Old/Previous SPSS script parsers should be slowly transitioned to utilize this function when possible to maximize code use.
The SPSS syntax script parser is focused on gathering details for use with fixed-width data files. This function scans for the following SPSS commands:
FILE HANDLE
DATA LIST
VARIABLE LABEL
VALUE LABEL
MISSING VALUE
The outputFormat
specified will determine the result object returned. This function currently supports the following formats.
data.frame
variableName - The variable name as defined in the script
Start - The start number index of the variable defined for the fixed-width format layout
End - The end number index of the variable defined for the fixed-width format layout
Width - The length of how many columns the variable uses in the fixed-width format layout
Attributes - Any SPSS attributes that are defined in the DATA LIST command. This is typically only for field formatting.
RecordNumber - Some fixed-width data files are considered "multi-line" where one record of data can span multiple rows in the file. The RecordNumber indicates which line the variable is assigned.
Labels - The descriptive label associated with the variable name to give more detail or context.
labelValues - For categorical variables a stored value will typically be assigned a longer label/definition. This string identifies these mappings. The '^' symbol is used to delimit each individual label value. Then additionally, the '=' is used to split the value from the left side of the '=' symbol, and the remaining right-hand side of '=' is the text label for that value.
dataType - A best-guess of the data type (either 'numeric' or 'character') without actually examining the data-file.
missingValues - If a MISSING VALUE clause is included in the script this will list the values that are considered 'Missing'. If multiple values specified, they will be delimited by a ';' (semi-colon) symbol.
returns an object containing information specified by the outputFormat
argument.
Tom Fink
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.