here is a step to check and flag those ID where multiple events occur within 7 days or the "frame year";[pre]data have;
input id date date9.;
frameY = intnx( 'year.4', date, 0) ;
format date framey date9. id 5. ;
cards;
1 10jan2005
1 17jan2005
2 10jan2005
2 16jan2005
2 9jan2005
3 5feb2006
3 5feb2007
4 5apr2008
4 4mar2009
5 7apr2010
;
proc sort out= work ;
by id date ;
run ;
data specials( keep= id frameY flag7day flagNyear) ;
frame = 0 ;
do until( last.id ) ;
set work ;
by id frameY ;
if not frame then frame = frameY ;
if first.frameY then do;
cases = 0 ;
framed = framey ;
end ;
cases+1 ;
if cases > 1 and not flag7day then do ;
if date - framed > 7 then framed = date ;
else flag7day = 1 ;
end ;
if last.frameY and cases > 1 then
flagNyear=1 ;
end ;
run ;[/pre]looks a bit similar to Art's suggestion
... View more