SetVarFormat Method (Python)
.SetVarFormat(varName,type,width,decimals). Sets the display format for a new variable. The argument varName is a string specifying the name of a new variable. The argument type is an integer that specifies one of the available format types (see Variable Format Types (Python)). The argument width is an integer specifying the defined width, which must include enough positions to accommodate any punctuation characters such as decimal points, commas, dollar signs, or date and time delimiters. The optional argument decimals is an integer specifying the number of decimal digits for numeric formats.
Allowable settings for decimal and width depend on the specified type. For a list of the minimum and maximum widths and maximum decimal places for commonly used format types, see Variable Types and Formats in the Universals section of the Command Syntax Reference, available in PDF from the Help menu and also integrated into the overall Help system.
- This method is only available in write mode.
- Setting the argument width for a string variable will not change the defined length of the string. If the specified value does not match the defined length, it is forced to be the defined length.
Example
cur=spss.Cursor(accessType='w')
cur.SetVarNameAndType(['numvar'],[0])
cur.SetVarFormat('numvar',5,2,0)
cur.CommitDictionary()
cur.close()