3

Is is possible in SPSS to store a value in a variable (not a variable created in a data set)?

For example I have a loop for which I want to pass the value 4 to all the locations in the loop that say NumLvl.

NumLvl = 4.
VECTOR A1L(NumLvl-1).
LOOP #i = 1 to NumLvl-1.
COMPUTE A1L(#i) = 0.
IF(att1 = #i) A1L(#i) = 1.
IF(att1 = NumLvl) A1L(#i) = -1.
END LOOP.
EXECUTE.
RTrain3k
  • 845
  • 1
  • 13
  • 27

1 Answers1

3

You can do this using DEFINE / !ENDDEFINE SPSSs Macro Facility, for example:

DEFINE !MyVar () 4 !ENDDEFINE.

You can then use !MyVar as a substitute for 4 wherever in your syntax you wish.

See DEFINE / !ENDDEFINE documentation for further notes.

Jignesh Sutar
  • 2,909
  • 10
  • 13