spssdictionary.GetUserMissingValues Function (R)

spssdictionary.GetUserMissingValues(variable). Returns the user-missing values for the specified variable in the active dataset. The argument can be a character string specifying the variable name or an integer specifying the index value of the variable (index values represent position in the dataset, starting with 0 for the first variable in file order). Variable names must match case with the names as they exist in the active dataset's dictionary.

  • The result is a list. The first element of the list has the name type and is a character string specifying the missing value type: 'Discrete' for discrete numeric values, 'Range' for a range of values, 'Range Discrete' for a range of values and a single discrete value, and NULL for missing values of a string variable. The second element of the list has the name missing and is a vector containing the missing values. The content of the vector for the different missing value types is shown in the following table.
    Table 1. Structure of the result
    result$type result$missing[1] result$missing[2] result$missing[3]
    'Discrete' Discrete value or NaN Discrete value or NaN Discrete value or NaN
    'Range' Start point of range End point of range NaN
    'Range Discrete' Start point of range End point of range Discrete value
    NULL Discrete value or NA Discrete value or NA Discrete value or NA
  • For string variables, returned values are right-padded to the defined width of the string variable.

Example

#List all variables without user-missing values
nomissList <- vector()
dict <- spssdictionary.GetDictionaryFromSPSS()
varnames <- dict["varName",]
for (name in varnames){
   vals <- spssdictionary.GetUserMissingValues(name)
   if (is.nan(vals$missing[1]) | is.na(vals$missing[1]))
      nomissList <- c(nomissList,name)
}
{if (length(nomissList) > 0) {
   cat("Variables without user-missing values:\n")
   cat(nomissList,sep="\n")}
else
   cat("All variables have user-missing values")
}