missingValues Property (Python)
The missingValues
property
of a Variable
object gets or
sets user-missing values. The missing values are specified as a tuple
or list of four elements where the first element specifies the missing
value type: 0,1,2, or 3 for that number of discrete values, -2 for
a range of values, and -3 for a range of values and a single discrete
value. The remaining three elements specify the missing values. When
getting missing values, the result is returned as a tuple with this
same structure.
- For string variables, returned values are right-padded to the defined width of the string variable.
- To specify LO and HI in missing value ranges, use the values returned by the spss.GetSPSSLowHigh function.
missingVals[0] | missingVals[1] | missingVals[2] | missingVals[3] |
---|---|---|---|
-3 | Start point of range | End point of range | Discrete value |
-2 | Start point of range | End point of range | None |
0 | None | None | None |
1 | Discrete value | None | None |
2 | Discrete value | Discrete value | None |
3 | Discrete value | Discrete value | Discrete value |
Examples
In the following examples, varObj is an instance of the Variable
class.
Get the user-missing values.
missingVals = varObj.missingValues
Specify the discrete missing values 0 and 9 for a numeric variable.
varObj.missingValues = [2,0,9,None]
Specify the range of missing values 9–99 for a numeric variable.
varObj.missingValues = [-2,9,99,None]
Specify the range of missing values 9–99 and the discrete missing value 0 for a numeric variable.
varObj.missingValues = [-3,9,99,0]
Specify two missing values for a string variable.
varObj.missingValues = [2,' ','NA',None]
Clear all missing values
varObj.missingValues = [0,None,None,None]