You can't use LAG on a variable you are calculating at the same time. So, first compute an intermediate term. I made it a "scratch" variable (note the '#'; that denotes a variable computed but not saved back to the dataset, since it is unneeded for anything but this).
COMPUTE #SE1_MX_SQR=SE_1_max**2.
COMPUTE x = (SUR_1_min - LAG(SUR_1_min))/SQRT(#SE1_MX_SQR+LAG(#SE1_MX_SQR)).
EXECUTE.
------------------------------
Rick Marcantonio
Quality Assurance
IBM
------------------------------
Original Message:
Sent: Thu October 13, 2022 09:33 AM
From: Daniel van Lammeren
Subject: QUESTION: kaplan-meier analysis
Hey Rick,
Thank you for your help! i do have some trouble with computing the new Z variable. i get the following error when trying to compute the new variable:
(SUR_1_min – LAG(SUR_1_min))/SQRT(SE_1_max**2+LAG(SE_1_max**2))

Any idea how to tackle this problem?
Thanks in advance!
------------------------------
Daniel van Lammeren
Original Message:
Sent: Wed October 12, 2022 04:46 PM
From: Rick Marcantonio
Subject: QUESTION: kaplan-meier analysis
The statistician got back to me. Here is what he said:
-----
This would require forming a test manually, but it's not terribly difficult to do, assuming independent groups:
- You can get the survival function estimates and their standard errors for the two distributions at the desired time point either by saving the survival function and its standard errors.
- Find the highest time point with saved values at or before the comparison point for each group. That will provide the estimates and standard errors for the comparison point.
- You can form a Z statistic to test equality at that point by using the difference in survival function estimates divided by its standard error.
- The standard error can be calculated as the square root of the sum of the squared standard errors for the two groups.
- To automate this somewhat, once the survival functions and standard errors are saved:
- Data>Select Cases and select if the time variable is less than or equal to the comparison point. Save out the selected cases to a new dataset.
- Activate the new dataset and use Data>Aggregate. Use the grouping variable as the Break variable. For summaries of variables, specify the saved survival function variable and specify the minimum value. Also specify the standard error variable and specify the maximum value. (This works because the survival function is monotonically decreasing and its standard error is monotonically increasing. That way you get the right pair of values.) Again save to a new dataset.
- Activate the new dataset. You should have just two cases.
- Transform>Compute: Assuming default names for survival function and SE variables, compute Z as (SUR_1_min – LAG(SUR_1_min))/SQRT(SE_1_max**2+LAG(SE_1_max**2)). The new Z variable for the second case will be what you want. The first case's value will be missing due to the use of the LAG function.
- There are multiple ways you can get a p value from here, the easiest of which is to use Transform>Compute and use SIG.CHISQ(Z**2,1) for a nondirectional test.
----
------------------------------
Rick Marcantonio
Quality Assurance
IBM
Original Message:
Sent: Wed October 12, 2022 12:23 PM
From: Daniel van Lammeren
Subject: QUESTION: kaplan-meier analysis
Hello IBM Community,
I have a question regarding a kaplan-meier survival analysis that i am currently working on. Here is the figure for context:

As you can see, the lines start to spread out and then they start to converge at around the 1000 day mark. I was wondering if the difference in survival at the 1000 day mark is significant, but i dont know how i can investigate this difference in SPSS.
Any help is welcome :)
------------------------------
Daniel van Lammeren
------------------------------
#SPSSStatistics