# Creating a timepoints variable in SPSS

#### saltycrocodileonion

##### New Member
I have collected 42 data points from participants (6 per day for 7 days), all of them at different times. Now I would like to compute a timepoints variable. The data is in long format, so each participant has multiple rows (42 to be exact, for each measurement time point). Now I also need a column with a time point variable, where the first row of a participant has the value 1 and the last 42.

How do I do that? Help is greatly appreciated.

#### Karabiner

##### TS Contributor
There exist more elegant solutions, but this here works too:

IF($casenum=1) time_point = 1 . EXECUTE . IF($casenum < 43) time_point = LAG(time_point)+1 .
EXECUTE .
IF($casenum >= 43) time_Point = LAG(time_point,42) . EXECUTE . HTH Karabiner #### Karabiner ##### TS Contributor Correction: IF($casenum=1) time_point = 1 .
EXECUTE .

IF(Missing(time_point) AND $casenum < 43) time_point = LAG(time_point)+1 . EXECUTE . IF(Missing(time_point) AND$casenum >= 43) time_Point = LAG(time_point,42) .
EXECUTE .

#### saltycrocodileonion

##### New Member
Thank you Karabiner! Its a good start I think. Now the only problem is that the timepoint needs to start at 1 again for each new participant. Since some the data points are missing, some participants don't have 42 rows.

#### Karabiner

##### TS Contributor
It would have been very nice to know this from the beginning.

I suppose you do not want to just have a variable which counts the actual timepoints
(e.g. someone with one missing time point would receive time points 1 to 41). Instead,
if someone missed e.g. time point 4, the new variable for that subject would contain
1 2 3 5 6 7... ?

In that case, based in which information can the syntax can know which particular data
points are missing?