Hello, I need to filter repeated measures if the dates (by id) are not 60 days apart. There are hundreds of id's in the dataset; I am showing three here. Person 1 can be reduced to a single date (because they're the same). Person 2 can be reduced to a single date (I figure choosing the earliest date makes the most sense). Person 3 has 2 dates that are far enough apart to keep, but a third that would cause that row to be dropped (again wanting to keep the earliest date). Dates can be repeated and a person can have any number of dates from 1-10 (although no one has 7-9 oddly enough). DATA have; input id date mmddyy10.; format date mmddyy10.; CARDS; 1 2/20/2016 1 2/20/2016 2 1/25/2016 2 1/28/2016 2 2/4/2016 2 2/4/2016 3 3/18/2016 3 3/20/2016 3 9/6/2016 ; RUN; DATA want; input id date mmddyy10.; format date mmddyy10.; CARDS; 1 2/20/2016 2 1/25/2016 3 3/18/2016 3 9/6/2016 ; RUN; Here's my logic for comparing dates, and an example of a person with three sorted dates: Case1: If date2-date1 <= 60, keep date1 and delete date2 For the next comparison date1 would be used again. If date3-date1 <=60, keep date1 delete date3 ==================================== Case2: If date2-date1 >= 60, keep both dates(rows) At this point, when keeping both dates, the next comparison must be done using the latest date. If date3-date2 >=60, keep both dates In this situation all three dates are retained. But had date3-date2 been <= 60 I would've dropped date3. Any help is appreciated.
... View more