Dear Sir/Madam

I have a panel dataset (each company has one or multiple years of data, but there are gaps) and I need to create a flag to identify cases in which there are at least 3 consecutive years of data, without deleting cases where there are not. Can anybody help me? Many thanks!

Kind regards,
João