3

I have a data set in SPSS containing a sequence of six variables from which I have to create a new variable which should contain the last value present in the sequence. Let's say the data look like this: (the second row contains all missing values but represents a case to which I'll merge some other variables later, so I need this too.)

DATA LIST  /V1 TO V6 1-6.
BEGIN DATA
423451

73453
929
0257
END DATA.

Now if I wish to generate a variable named lastscr which should have values 1, ., 3, 9, 7. Can anyone help me on how should I do it in SPSS? I could not find any clue about it. Thank you in advance for any help.

Blain Waan
  • 393
  • 2
  • 4
  • 17

1 Answers1

3

This can easily be done with the DO REPEAT command:

DO REPEAT Var = V1 TO V6.
   IF NOT(SYSMIS(Var)) lastscr = Var.
END REPEAT.
mirirai
  • 1,365
  • 9
  • 25