This is really a 2-part question.

I haven't worked with survival data in years, and I'm a bit stumped. Some examples (including this forum, text books, etc) show survival analysis data in the wide format (single line of data per person with a start and event or censor time) while others show it in long format (each person may have multiple lines of data depending on the number of observation/measurement points with one eventually indicating an event or censored time). I can convert my data, but which format should it be in??!

Mine is currently in long format, with each line representing a procedure within a visit, so each person can have several lines per date/visit and several visits.

ID  Visit  Proc Event
1   Jan    A    0
1   Jan    B    0
1   Feb    T    0
2   Jan    A    1
3   Jan    B    0
3   Feb    C    0
3   Mar    B    0   

With wide format I could easily calculate beginning and end times, but is that right? If long is better, then how do I calculate those times in SPSS? Some sort of combination of lags nestled in if commands?


  • $\begingroup$ Sorry, I don't know what happened with my data example $\endgroup$
    – JWislar
    Nov 1, 2016 at 20:45
  • $\begingroup$ I would nose around ats.ucla.edu/stat/spss/topics/data_management.htm $\endgroup$
    – seanv507
    Nov 1, 2016 at 21:14
  • $\begingroup$ The answer depends on software you're using. Different software use different data formats. $\endgroup$
    – Tim
    Nov 12, 2017 at 16:57

1 Answer 1


This is not a full answer, but I'll post it as an answer because I'll write more than there is room for in a comment.

First of all, what is your research question? What hypothesis do you want to test with a survival analysis?

A couple of practical issues:

  1. Are all events the same or are there different kinds of events?
  2. Is an event a direct result of a procedure, or are events assumed to have happened some time before the next visit? For example, ID #2 in your example data set had an event recorded in January. Did this event occur before the visit?

In short, in a basic Cox regression (standard, semi-parametric survival model), there is one line per subject with data on time in the study, whether they had an event, and baseline variables that might be associated with having an event. In more complex models, an the Cox regression model can be extended with different lines for different time periods. If you have time-dependent covariates (covariates that are measured at several times and may change over time), repeated events (a kind of event that might occur several times) or competing risks (different kinds of events that might be associated with the same covariates, such as having a myocardial infarction vs. having a stroke) you need to use an extended Cox regression model, but if not, you should be fine with the basic model.


In a comment you stated that events can only occur once per subject, and that the "procedures" really doesn't matter. The only candidate for a time-dependent covariate is age. I think you should opt for at standard Cox regression model in this case. Age is a special kind of time-dependent variable because it has a perfect correlation with time. You will get the same estimated hazard ratios from using age at baseline compared to using age as a time-dependent covariate. The reason for this is that because at any specific point in time, the difference between any pair of subject's ages will be the same. If person A is 20 years at baseline and person B is 30 years at baseline, there will always be a difference of 10 years regardless of how much time that has passed. And in Cox regression, it is the difference between an individual who has an event and all other individuals that remain under risk (i.e. has not had an event or been censored) that is important. Since this difference is the same either way, you will get the same Estimates and you might as well make life easier by using a standard Cox regression model.

So to answer your question: in this case, your data should be in the wide format with a variable representing the time until censoring or having an event, another variable representing the event/censoring status, and then your baseline covariates (including age).

I hope this helps.

  • $\begingroup$ Events are treatment failures and are already defined in my data. Censoring events are basically when people age out of the data. I'm comparing people who have had Treatment X to those who have not, so they can contribute time before and after the treatment. The other procedures are irrelevant unless they are the result of Treatment X failing (then they're defined as an event). An event/failure can only occur once. There are no competing risks. Age could be a time-dependent variable as the data set extends over several years. $\endgroup$
    – JWislar
    Nov 1, 2016 at 22:29
  • $\begingroup$ Thank you very much! That's exactly the answer I was looking for. You've been very helpful. $\endgroup$
    – JWislar
    Nov 2, 2016 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.