SPSSINC PROGRAM testpgm.mypgn x=age y = income z=.05.
programname specifies the Python function to be run. It has the form modulename.functionname or, if already defined in the current session, it can just be functionname. Note that modulename and functionname are case sensitive.
arguments. The argument values depend on the particular program being run. Consult the documentation for the particular program to find the specifications.
=========
Then you would put the macro reference in the SPSSINC PROGRAM line so that it would be expanded as in regular syntax.
You would use sys.argv in the begin program block to pick up the arguments from the SPSSINC PROGRAM command. Here is an example of how to use sys.argv. The macro would be specified on the spssinc program line/
begin program python.
def dofreq():
import sys, spss
for f in sys.argv[1:]
spss.Submit("""freq %s""" % f)
end program.
spssinc program dofreq educ jobcat.
Hi Jon,
you're right when i did it manually it is working with the comma
But when I use this
/begin program.
import spss, spssaux
import re
vardict = spssaux.VariableDict()
selected = []
for v in vardict:
keys = v.ValueLabels.keys()
values = v.ValueLabels.values()
if keys:
keymatch = [re.search(r"3", key, re.I) for key in keys]
valuematch = [re.search(r"weiß+", value, re.I) for value in values]
both = zip(keymatch, valuematch)
test = [key is not None and val is not None for (key,val) in both]
if any(test):
selected.append(v.VariableName)
print selected
spss.SetMacroValue("!selectedvars36", "\n".join(selected))
end program.
begin program.
variables = '!selectedvars36' # Specify variables here.
value = 1 # 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./
i got an error message:
Traceback (most recent call last):
File "<string>", line 6, in <module>
File
"C:\PROGRA~1\IBM\SPSS\STATIS~1\24\PYTHON\Lib\site-packages\spssaux\spssaux.py",
line 1249, in expand
raise ValueError, _msg19 + v
ValueError: Invalid variable or TO usage: !selectedvars36
--
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
Free forum by Nabble | Edit this page |