Hi Statalist,

I'm working with a dataset where the variables are collected over about 20 years and each year the data collected are organised into 'waves' with additional people being added to the various waves as the years went on. I need to identify people who have information on their depressive status (psceda) in the one wave before and one wave after a hip fracture event (hefrac). So essentially I need to identify which individuals have data pre event and post event, across all the waves. Anyone know any code to achieve this please?

I've got as far as being able to identify which individuals have data for 3 waves but haven't been able to figure out to specify the consecutive element
(count if hefracwaves >=3 & hefracwaves !=.)

Thanks in advance