SetValueNumeric Method (Python)
.SetValueNumeric(varName,varValue). Sets the value for the current case for a numeric variable. The argument varName is a string specifying the name of a numeric variable. The argument varValue specifies the numeric value of this variable for the current case.
- This method is available in write or append mode.
- The
CommitCase
method must be called for each case that is modified. This includes new cases created in append mode. - The Python data type None specifies a missing value for a numeric variable.
- Values of numeric variables with a
date or datetime format should be specified as Python
time.struct_time
ordatetime.datetime
objects, which are then converted to the appropriate IBM® SPSS® Statistics value. Values of variables withTIME
andDTIME
formats should be specified as the number of seconds in the time interval.
Example
DATA LIST FREE /var1 (F) var2 (F).
BEGIN DATA
11 12
21 22
31 32
END DATA.
BEGIN PROGRAM.
import spss
cur=spss.Cursor(accessType='w')
cur.SetVarNameAndType(['var3'],[0])
cur.SetVarFormat('var3',5,2,0)
cur.CommitDictionary()
for i in range(cur.GetCaseCount()):
cur.fetchone()
cur.SetValueNumeric('var3',3+10*(i+1))
cur.CommitCase()
cur.close()
END PROGRAM.