data mydata;
input id : 3. dat4 : mmddyy10.;
format dat4 mmddyy10.;
datalines;
1 10/1/1999
1 11/1/1999
1 12/1/1999
1 1/1/2000
1 2/1/2000
1 3/1/2000
1 4/1/2000
1 5/1/2000
1 6/1/2000
2 10/1/1999
2 11/1/1999
2 12/1/1999
2 1/1/2000
2 2/1/2000
2 3/1/2000
2 4/1/2000
2 5/1/2000
2 6/1/2000
3 7/1/2002
3 8/1/2002
3 9/1/2002
3 10/1/2002
3 11/1/2002
3 12/1/2002
3 4/1/2007
3 5/1/2007
3 6/1/2007
;
%macro delFun( );
%do i =1 %to 3;
proc sql noprint;
select id, count(*), intck('month',min(dat4),max(dat4))+1 into :id,: obsCount, :monthDiff
from mydata
where id=&i
group by id;
quit;
%put id= &id numObs =&obsCount month diff = &monthDiff;
/* delete the dataset which has the discontinous month */
%let a = %eval(&obsCount);
%let b = %eval(&monthDiff);
%if &a ^= &b %then %do;
proc sql;
delete from mydata
where id = &id;
quit;
%end;
%put id =&id a=%eval(&obsCount) b=%eval(&monthDiff);
%end;
%mend;
options mprint nosymbolgen nomlogic;
%delFun()