Site icon DW Faisalabad

Remove Value Label from Multiple Variables

Question

“I’d like to completely remove the value label from a value for many variables at once. Is there an easy way to accomplish that?”

SPSS Python Syntax Example

begin program.
variables = ‘v1 to v5‘ # Specify variables here.
value = 3 # Specify value to unlabel here.
import spss,spssaux
vDict = spssaux.VariableDict(caseless = True)
varList = vDict.expand(variables)
for var in varList:
valLabs = vDict[vDict.VariableIndex(var)].ValueLabels
if str(value) in valLabs:
del valLabs[str(value)]
vDict[vDict.VariableIndex(var)].ValueLabels = valLabs
end program.

Description

Exit mobile version