shenliang_111 发表于 2011-12-16 11:31 
可是,当我加入时间变量,加入求的是每天的行业收益率。小弟修改代码如下:
data a;
input n r sic value date ddmmyy8.;
format date ddmmyy10.;
cards;
1 0.1 1 109 01-12-10
2 0.2 1 209 01-12-10
3 0.3 1 167 01-12-10
4 0.1 2 123 01-12-10
5 0.2 2 200 01-12-10
6 0.3 2 210 01-12-10
7 0.4 2 342 02-12-10
8 0.12 1 223 02-12-10
1 0.29 1 560 02-12-10
;
proc sql;
create table result as
select distinct a.n,a.r,a.sic,sum(b.value*b.r)/sum(b.value) as weight label='weighted return' format=7.2 from
a join a b
on a.sic=b.sic and
a.n ne b.n and a.date= b.date
group by a.n and a.date
order by a.n;
quit;
(为啥运行结果就是不对的呢??)盼望指教啊