Login  Register

Re: Deleting specific value labels

Posted by Jon K Peck on Jun 17, 2015; 1:28pm
URL: http://spssx-discussion.165.s1.nabble.com/Deleting-specific-value-labels-tp5729847p5729851.html

This little program will search all the variables, look at their value labels, and delete the "no answer" label if present.  For simplicity, I assumed that this label could occur only once for each variable, but that can be adjusted if needed.

begin program.
import spss, spssaux

vardict = spssaux.VariableDict()
for v in vardict:
    vallbls = v.ValueLabels
    for k, vl in vallbls.items():
        if vl == "no answer":
            del(vallbls[k])
            v.ValueLabels = vallbls
            break
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        emma78 <[hidden email]>
To:        [hidden email]
Date:        06/17/2015 02:59 AM
Subject:        [SPSSX-L] Deleting specific value labels
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi,
just a little question regarding value labels.
Is it possbible to delete  a specific value label from a lot of variables
according to the text/label ? For example delete all value labels with 'no
answer' in it?

Thank you!



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Deleting-specific-value-labels-tp5729847.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD