如何使用语法检查变量的度量 (nominal/ordinal/scale)?

How can I check the measure (nominal/ordinal/scale) of a variable using syntax?

我想使用语法找到变量的度量,然后在 If 语句中使用它。这可能使用语法吗?

例如,如果我有两个变量 a(名义)和 b(有序):

DO IF (a is nominal?)
...
END IF

您可以创建数据中所有名义变量的列表。在以下示例中,列表将存储在宏调用 !noms:

SPSSINC SELECT VARIABLES MACRONAME="!noms" /PROPERTIES LEVEL=NOMINAL.
* now, for example you can run frequencies on all nominal variables.
freq !noms.

如果要转换所有名义变量,可以使用 do repeat。例如:

do repeat NomVrs=!noms.
recode NomVrs ("cat2"="persian").
end repeat.

如果你只想测试一个特定的变量(在本例中称为AmInominal),你可以这样使用宏:

define DoIfNom ()
    !do !vr !in (!eval(!noms))
        !if (!vr="AmInominal") !then
               variable label AmInominal "this variable is indeed nominal".
               recode AmInominal ("cat2"="persian").
               frequencies AmInominal.
        !ifend
    !doend
!enddefine.

DoIfNom.