select count(distinct name) into:num
from b;
select distinct name into:num1-:num%left(&num)
from from b;
quit;
%macro a;
%do i=1 %to #
proc sort data=a;
by num&i;
run;
data c&i;
set a;
by num&i;
if first.num&i. then do;first_num&i=num&i.; flg&i=0;end;
if num&i ne first_num&i then flg&i+1;
if last.num&i. and flg&i=0 then list&i=num&i;
run;
%end;
%mend a;
%macro b;
data d;
set a(drop= %do j=1 %to # list&j %end;);
run;
%mend b;
%b
;
data _null_;
if 0 then set have;
array cha[*] _character_;
array num[*] _numeric_;
call symputx ("nchar",dim(char));
call symputx ("nnum",dim(num));
stop;
run;
data _null_;
set have end=last;
array cha[*] _character_;
array num[*] _numeric_;
array first_cha(&nchar) _temporary_;
array first_num(&nchar) _temporary_;
array flg_cha(&nchar) (&nchar*0);
array flg_num(&nnum) (&nnum*0);
length list $100;
if _n_=1 then do;
do i=1 to &nchar;
first_cha(i)=cha[i];
end;
do i=1 to &nnum;
first_num(i)=num[i];
end;
end;
do i=1 to &nchar;
if cha[i] ne first_cha(i) then flg_cha(i)+1;
end;
do i=1 to &nnum;
if num[i] ne first_num(i) then flg_num(i)+1;
end;
if last=1 then do;
do i=1 to &nchar;
if flg_cha(i)=0 then list=catx('',list,vname(cha[i]));
end;
do i=1 to &nnum;
if flg_num(i)=0 then list=catx('',list,vname(num[i]));
end;
call symput ('mlist',list);
end;
run;
data have;
set have (drop=&milst);
run;