I would do it similar to what mkeintz suggested with a couple small but important enhancements. You need your data set to be sorted by ID and DATE, and also have by ID DATE; in the data step:
data HAVE;
input ID $1-5 @7 DATE mmddyy10.;
format DATE mmddyy10.;
lines;
16602 07/20/2015
16602 07/25/2015
16602 07/28/2015
20302 03/16/2016
20302 03/18/2016
20302 03/25/2016
20302 02/18/2015
;
proc sort data=HAVE;
by ID DATE;
run;
data WANT (drop=FIRSTDATE);
set HAVE;
by ID DATE;
retain FIRSTDATE;
if first.ID or DATE-FIRSTDATE>7 then
do;
FIRSTDATE = DATE;
CLUSTER+1;
end;
run;
Hope this helps.
... View more