-1

My previous organisation used SAS, but my current one uses SPSS. I have longitudinal dataset to analyse. What is the SPSS equivalent syntax for first.ID and last.ID? In SAS, the syntax goes,'if first.ID and last.ID then do....;'

I apologised if this post is repeated but I couldn't find them in the archives. Thank you very much for your help, I appreciate it.

Cheers, Meill

Meill
  • 1

1 Answers1

0

I think what you want to do is navigate to Data>Indentify Duplicate Cases and select your ID variable to identify duplicates by.

Do this twice, first time around let it run with default settings, a variable named "PrimaryLast" is appended to your dataset. for the second run select the first case of the ID to be primary, a variable "PrimaryFirst" is appended.

Now you have the beginning and the end of the data for each case denoted by those variables

Alternatively, this syntax should also do the trick:

sort cases by ID(a). 

compute x1 = lag(ID). 
create x2 = lead(ID,1).
recode x1 x2 (sysmis=0).  

if x1 <> ID first = 1. 
if x2 <> ID last = 1. 

The lag function "pushes down" your ID values one cell in a new variable, the lead function "pushes them up", so wherever theres a divergence between x1 and the ID or x2 and the ID is the first or last ID respectively.

ragamuffin
  • 460
  • 2
  • 12