proc sql;
create table have1 as select distinct stkcd, id1
from have group by stkcd;
create table have2 as select stkcd, count(*) as n
from have1 group by stkcd;
quit;
data want;
merge have have2;
by stkcd;
if n ne 1 then equal=0;
else equal=1;
drop n;
run;
qinly10 发表于 2013-1-11 22:28
data have;
input stkcd $ year id1 $;
cards;
proc sql;
create table have1 as select distinct stkcd, id1
from have group by stkcd;
WARNING: GROUP BY 子句已变换为 ORDER BY 子句,因为 SELECT 子句和相关表的表达式的可选 HAVING 子句都没有引用汇总函数。
这是日志的提示。
data temp;
set temp;
by stkcd;
retain id2;
if first.stkcd then id2=id;
if last.stkcd then do;
if id2=if then equal=1;
else equal=0;
output;
end;
keep stkcd equal;
run;