spssdictionary.SetUserMissing Function (R)

spssdictionary.SetUserMissing(datasetName,variable,format,missings). Sets user-missing values for a specified variable. This function is used to define user-missing values for new IBM® SPSS® Statistics datasets created with the SetDictionaryToSPSS function.

  • The argument datasetName is the name of the IBM SPSS Statistics dataset as specified on the call to the SetDictionaryToSPSS function used to create the dataset.
  • The argument variable 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 argument format specifies the missing value type: missingFormat['Discrete'] for discrete values, missingFormat['Range'] for a range of numeric values, and missingFormat['Range Discrete'] for a range of numeric values and a single discrete numeric value.
  • The argument missings is a vector specifying the missing values. The content of the vector for the different missing value types is shown in the following table.
    Table 1. Specifications for arguments to SetUserMissing
    format missingvals[1] missingvals[2] missingvals[3]
    missingFormat['Discrete'] Discrete value (optional) Discrete value (optional) Discrete value (optional)
    missingFormat['Range'] Start point of range End point of range Not applicable
    missingFormat['Range Discrete'] Start point of range End point of range Discrete value
  • Missing values for string variables cannot exceed 8 bytes. (There is no limit on the defined width of the string variable, but defined missing values cannot exceed 8 bytes.)
  • The SetUserMissing function should be called after SetDictionaryToSPSS and before calling EndDataStep.

Examples

Specify the three discrete missing values 0, 9, and 99 for a new numeric variable.

spssdictionary.SetUserMissing("results","newvar",
                               missingFormat["Discrete"],c(0,9,99))

Specify the range of missing values 9–99 for a new numeric variable.

spssdictionary.SetUserMissing("results","newvar",
                               missingFormat["Range"],c(9,99))

Specify the range of missing values 9–99 and the discrete missing value 0 for a new numeric variable.

spssdictionary.SetUserMissing("results","newvar",
                               missingFormat["Range Discrete"],c(9,99,0))

Specify missing values for a new string variable.

spssdictionary.SetUserMissing("results","newvar",
                               missingFormat["Discrete"],c(' ','NA'))