SetVarNMissingValues Method (Python)
.SetVarNMissingValues(varName,missingFormat,missingVal1,missingVal2,missingVal3). Sets user-missing values for a new numeric variable. The argument varName is a string specifying the name of a new numeric variable. The argument missingFormat has the value 0 for a discrete list of missing values (for example, 0, 9, 99), the value 1 for a range of missing values (for example, 9–99), and the value 2 for a combination of a discrete value and a range (for example, 0 and 9–99). Use the SetVarCMissingValues method to set missing values for new string variables.
- This method is only available in write mode.
- To specify LO and HI in missing value ranges, use the values returned by the spss.GetSPSSLowHigh function.
missingFormat | missingVal1 | missingVal2 | missingVal3 |
---|---|---|---|
0 | Discrete value (optional) | Discrete value (optional) | Discrete value (optional) |
1 | Start point of range | End point of range | Not applicable |
2 | Start point of range | End point of range | Discrete value |
Examples
Specify the three discrete missing values 0, 9, and 99 for a new variable.
cur=spss.Cursor(accessType='w')
cur.SetVarNameAndType(['numvar'],[0])
cur.SetVarNMissingValues('numvar',0,0,9,99)
cur.CommitDictionary()
cur.close()
Specify the range of missing values 9–99 for a new variable.
cur=spss.Cursor(accessType='w')
cur.SetVarNameAndType(['numvar'],[0])
cur.SetVarNMissingValues('numvar',1,9,99)
cur.CommitDictionary()
cur.close()
Specify the range of missing values 9–99 and the discrete missing value 0 for a new variable.
cur=spss.Cursor(accessType='w')
cur.SetVarNameAndType(['numvar'],[0])
cur.SetVarNMissingValues('numvar',2,9,99,0)
cur.CommitDictionary()
cur.close()