hqs811 发表于 2014-7-30 11:02 
多谢指正,以下定义了unique group和weak unique group.
Definition(Unique Group): A number of groups ...
实在是不太懂楼主具体要做出什么样的数据。
以下代码可能是需要的步骤,仅供参考:
data test;
input Title & $10. Authors $40. Number_authors ;
authors=upcase(authors);
cards;
Title 1 Name A | Name B 2
Title 2 Name A | Name B | Name C 3
Title 3 Name A | Name C | Name E | Name Z 4
TITLE 4 NAME A 1
TITLE 5 NAME F | NAME Z 2
;
data test1;
set test;
if Number_authors=1 then do;
author1=authors;
output;
end;
else do i=1 to number_authors-1;
author1=strip(scan(authors,i,"|"));
do j=i+1 to number_authors;
author2=strip(scan(authors,j,"|"));
output;
end;
end;
keep author1 author2 title;
run;
proc sort data=test1;
by author1 author2;
run;
data weak_unique;
set test1;
by author1 author2;
retain titles;
if first.author2 then titles=cats(title);
else titles=catx(", ",titles, title);
if last.author2;
drop title;
run;