|
|
5#

楼主 |
发表于 2010-2-6 00:40:14
|
只看该作者
Re: 重合数据的问题
[code:2lvtqqig]data x;
input com $ date yymmdd8. trade source $;
year = year(date);
format date yymmdd10.;
cards;
A 20060201 5 a
A 20060201 6 b
A 20070502 2 a
A 20070502 2 a
A 20070503 3 b
A 20080101 5 a
A 20080101 5 b
B 20070101 2 b
C 20060101 6 a
C 20060101 6 b
;
proc sql;
create table y1 as select year, source, count(distinct com) as inSource from x group by year, source;
create table y2 as select year, count(com) as both from (select year, com from x group by year, com having count(distinct source) > 1) group by year;
quit;
proc transpose data = y1 out = y11(drop = _name_);
by year; id source;
var inSource;
run;
data y;
merge y11 y2; by year;
if missing(a) then a = 0; if missing(b) then b = 0; if missing(both) then both = 0;
run;
proc print; run;[/code:2lvtqqig]
I don't see why I am doing that. JingJu |
|