spss.SetMacroValue Function (Python)
spss.SetMacroValue(name, value). Defines a macro variable that can be used outside a program block in command syntax. The first argument is the macro name, and the second argument is the macro value. Both arguments must resolve to strings.
- The argument specifying the macro value cannot contain
the characters
\
or^
unless they are contained within a quoted string.
Example
DATA LIST FREE /var1 var2 var3 var4.
begin data
1 2 3 4
end data.
VARIABLE LEVEL var1 var3 (scale) var2 var4 (nominal).
BEGIN PROGRAM.
import spss
macroValue=[]
macroName="!NominalVars"
varcount=spss.GetVariableCount()
for i in range(varcount):
if spss.GetVariableMeasurementLevel(i)=="nominal":
macroValue.append(spss.GetVariableName(i))
spss.SetMacroValue(macroName, macroValue)
END PROGRAM.
FREQUENCIES VARIABLES=!NominalVars.