Hi @Reeza, I have included the tables below (So sorry for not doing so the first time!!), and made the new variable names I am looking to create in blue. When I have previously done this there was no missing values so each time point (i.e. Death1 to Deathn) corresponded to 1 time point each (i.e. an interval of 1) so the array statement would create the timeptn variable from the i variable in the do statement, the new death variable would be created for each person, and there was no need to create this interval variable to account for the greater time periods. The interval variable refers to how many sequential time points (called Death1 to Deathn) that data point corresponds to. For example, ID 1 does not have an observation at Death1 (i.e. time point 1 which corresponds to 1 interval). However, they do have a value at Death2 (i.e. time point 2, or the next time interval). As such, I want to create this interval variable to let me know that this first time point (that corresponds to this row for that patient) actually represents two possible time points (i.e. 2 intervals of time) - Death1 and Death2. Hopefully that clears things up, and thank you so much for taking a look! Table 1: Wide data without flags ID Duration Event Death1 Death2 Death3 Death4 Death5 Death6 1 3 1 . 0 1 2 5 0 0 0 . . 0 3 3 0 . . 0 4 1 1 1 5 6 0 . . . . . 0 Table 2: Long Data Transformed Correctly ID Duration Event Timeptn Death1 Death2 Death3 Death4 Death5 Death6 Interval_Length Death 1 3 1 1 . 0 1 2 0 1 3 1 2 . 0 1 1 1 2 5 0 1 0 0 . . 0 1 0 2 5 0 2 0 0 . . 0 1 0 2 5 0 3 0 0 . . 0 3 0 3 3 0 1 . . 0 3 0
... View more