SPSS Tutorials

BASICS REGRESSION T-TEST CHI-SQUARE TEST ANOVA

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

Previous tutorial: Split String Variable into Components

Next tutorial: Move all Files from Subfolders to Main Folder

Let me know what you think!

*Required field. Your comment will show up after approval from a moderator.

This tutorial has 3 comments