Hello everyone! The coverage for an insurance product i'm dealing with could be paid in upfront from 1-12 months. For example, in the picture below, the first person had bought seven consecutive one month policies and the second guy has bought a 3 months policy followed by a 9 months policy (there could be gaps)(first column - ID, Second column gender(irrelevant), third column - start of coverage date, fourth column - end of coverage date). Now I want to find someone who has paid for 12 months worth of coverage (regardless of how, could be 12 month in one go, 3+3+3+3 combination etc) and has proceeded with another 12 months worth of coverage. This is the solution I came up with. Data workone.testingrenewal4; Set workone.sorted2; Format Inception_date Supposed_end date1 date2 date9.; date1 = lag(Inception_date); date2 = lag(Supposed_end); By ic; If first.ic then do; Inception_date = Startdate; Supposed_end = (INTNX('YEAR', startdate ,1, 'sameday')-1); end; else if date1<startdate<date2 then do; Inception_date = date1; Supposed_end = date2; end; else if startdate>=date2 then do; Inception_date = Startdate; Supposed_end = (INTNX('YEAR', startdate ,1, 'sameday')-1); End; Run; essentially i want the codes to identify the first time a person has contributed and build a 12 month period using the startdate where the start of the 12 month coverage would =startdate (called Inception_date) and the end of the coverage would be 12 months from startdate (called supposed_end). If its not the first payment under the person then i want to observe whether the following payment was made within the 12 months period previously built. If yes, then I want the codes to assign the same Inception_date and supposed_end dates to the dataline. If the person had bought coverage after the pervious 12 months perios, then i want the codes to assign a new inception date based on the startdate of the newly purchased coverage. With that I'd be able to count the number of months in each built 12 month period. The results are not coming out like how i want them and I'm kinda new to SAS programming, so would appreciate if anyone can help improve the codes. Thanks!
... View more