proc sql noprint;
select name,count(*) into: name separated by ' ',: no
from temp;
quit;
%let list=;
%let i=1;
%do %while ( &i<=&no);
%let t=%scan(&name,&i);
data _null_;
set &old.(obs=&obs keep=&t);
temp=lag(&t);
if _n_=2 ;
if missing(&t) and missing(temp) then call symput('list', "&list."||" "||"&t." );
run;
%let i=&i+1;
%end;
data &new.;
set &old.;
drop &list;
run;
%mend check;