Hi,

I would like to apologise as I am unable to post the data sample here for you all, as the dataset I am working is in restricted environment (a virtual computer) which does not allow me to extract sample data. But I will make a effort to describe it.

I have a dataset where participants eGFR observations are longitudinal in nature. That is 1 person might have many eGFR observation. However, I am only interested in the values three years prior and one year after the treatment date in order for them to define cases. I have arrived at a point where I have kept all the observations by each person who have eGFR values recorded three year before date_record and one year after date_record.

In order to define cases, I am interested if the observation only has egfr<=60 three year prior and one year later from txt_date, if there is observation with egfr>60 for a participant within three year prior and one year after txt_date, then I wish to exclude participants from my data. At the moment I am having problem to code this part. I am creating a sample data below

again I am very sorry to post it without data, but please od understand my limitations.
Id txt_date date_ckd egfr case
1 2007 2004 63 exclude
1 2007 2005 46 exclude
1 2007 2006 55 exclude
1 2007 2008 67 exclude
2 2008 2005 66 yes_case
2 2008 2006 75 yes_case
2 2008 2006 55 yes_case
2 2008 2009 55 yes_case
3 2009 2006 42 exclude
3 2009 2006 43 exclude
3 2009 2007 71 exclude
3 2009 2008 77 exclude
3 2009 2010 30 exclude
Any help would be appreciated.