spss.GetVarAttributeNames Function (Python)

spss.GetVarAttributeNames(index). Returns the names of any variable attributes, as a tuple, for the variable in the active dataset indicated by the index value. The argument is the index value. Index values represent position in the active dataset, starting with 0 for the first variable in file order.

Example

#Create a list of variables that have a specified attribute
import spss
varList=[]
attribute='demographicvars'
for i in range(spss.GetVariableCount()):
   if (attribute in spss.GetVarAttributeNames(i)):
      varList.append(spss.GetVariableName(i))
if varList:
   print("Variables with attribute " + attribute + ":")
   print('\n'.join(varList))
else:
   print("No variables have the attribute " + attribute)