I have the following data set which is sorted by ID, Time and Default. The variable default can take two values 1 and 0 with 1 being default and 0 being non default.
data test;
infile datalines;
input ID Time$ Default;
datalines;
1 Jan13 0
1 Feb13 0
1 Mar13 1
2 Jan13 1
2 Feb13 0
2 Mar13 0
3 Jan13 1
3 Feb13 1
3 Mar13 0
3 Apr13 1
4 Jan13 0
4 Feb13 0
4 Mar13 0
The task that I am trying to achieve is to find the number of occurrences of default and the time difference between defaults by ID. The definition of default occurrence is when a customer goes in default, then pays back in time and then defaults again. For example for ID 1, there is one default event and the duration is 3 months. Similarly ID 2 and 3 have default events with duration of 3 and 4 months. However ID 4 has no default event.
I want to achieve this in SAS and have tried using RETAIN, FIRST. and LAST. option but can't get anywhere. If anyone can point me in the right direction it would be really useful.
Many thanks,
... View more