Skip to content
Advertisement

Gaps and Islands Months only

I am working with a data set of clients and their date records. I am trying to apply a gaps and island problem only using MONTHS,( currently var char ‘YYYYMM’). I need to take individual records and group by gaps in months(irregardless of year). I cant figure out how to go from:

Current

To: Final Result

Advertisement

Answer

One method is uses dense_rank() and truncating dates to months:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement