My time series data consists of 1 data point per month. I need to make a new variable that averages the last three entries in the time series for each case. The problem is that not all cases have the same number of entries. For example, lets say each case represents a student, and each month the student is assessed and receives a score. Some students stay in the program for three years, others for just one, ect. However, they all still take an assessment each month. Therefore, some students have 36 data points (assessments) while others have just 12. It is easy to create a new variable that averages the first three scores, but more difficult to create one that averages the last three scores. Does anyone have any advise?

Just as an aside, I am averaging the first and last scores to account for a poor monthly assessment (ie: student had a cold and tested poorly, ect), as we are looking to see if there is general improvement over time, rather than looking at a snapshot of an initial test and a final test.

Please feel free to post questions or critique my logic. Examples of simple create syntax below:

Simple create new variable syntax for average of first three assessments:

COMPUTE F3TM_AVERAGE = (total_tpm_1+total_tpm_2+total_tpm_3)/3.

EXECUTE.