How about a code like this?
data have;
length name1-name7 $20;
infile datalines dsd missover;
input name1--name7;
datalines;
Jones,Jones,Smith,Jones,Smith,Jones,
Matthews,Matthews,Matthews,Stewart,Matthews,Stewart,Matthews
Jones,Jones,Jones,David,David,David,David
Heath,Davis,Heath,Davis, , ,
Wallis,King,Wallis,King,Wallis,Wallis,King
Williams,Williams,Williams,Williams,Jones, ,
Smith,Lucas,Lucas,Lucas,Lucas,Lucas,
;
run;
data want;
set have;
array a_name{7} name1-name7;
flg=0;
do i=2 to dim(a_name)-2;
if a_name{i} ^= '' then do;
if a_name{i-1}=a_name{i+1} and
a_name{i}=a_name{i+2} and
a_name{i}^=a_name{i+1} then do;
flg=1;
if flg then leave;
end;
end;
end;
if flg;
drop i flg;
run;
... View more