Re: delete specific value label
Posted by
Jon Peck on
May 20, 2021; 7:39pm
URL: http://spssx-discussion.165.s1.nabble.com/delete-specific-value-label-tp5740529p5740545.html
Here is a fully worked out solution using SPSSINC PROGRAM. First it defines the function deletelabel. Run this once.
begin program python3.
import spssaux
vardict = spssaux.VariableDict(caseless=True)
def deletelabel():
vars = sys.argv[1:-1]
val = sys.argv[-1]
for v in vars:
vls = vardict[v].ValueLabels
if val in vls:
vls.pop(val)
vardict[v].ValueLabels = vls
end program.
Then, in your macro or wherever you would have called the original program, run code like this. The last item is the value whose label should be deleted delete.
spssinc program deletelabel jobcat minority 1.
The variable list could be a macro:
spssinc program deletelabel !victims 1.
You need to install SPSSINC PROGRAM from the Extension Hub.
This code assumes that the data are defined before running that begin program. If not or the data might change, just move the vardict line inside the deletelabel function (indenting as the other lines are).
ok, thank you, but this is far beyond my knowledge. :-( Is there another way
to delete the value labels for variables which are in a macro?
--
Sent from: http://spssx-discussion.1045642.n5.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