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
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
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.