How can I check the measure (nominal/ordinal/scale

2019-07-13 17:35发布

I would like to find the measure of a variable using syntax and then use this in an If-statement. Is this possible using syntax?

For example, if I have two variables a (nominal) and b (ordinal):

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

标签: spss
1条回答
你好瞎i
2楼-- · 2019-07-13 18:08

You can create a list of all the nominal variables in your data. In the following example the list will be stored under the macro call !noms:

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

If you want to transform all the nominal variables you can use do repeat. For example:

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

If you want to test only one specific variable (in this example called AmInominal), you can use a macro this way:

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.
查看更多
登录 后发表回答