zhangwenteng 发表于 2014-5-14 10:41 
这个就是一个简单的数据操作和数据转换,太简单了,实在写不下去了。。。谁给你接着写吧。
多谢!我现在已经熟练很多,已将你的回答设为最佳答案!应该还有500个论坛币给你吧。
最后还有个问题啊,你看下面这段,是算一天的r1和add_r的(就是%let date_str=的那一天)。我想算一个时间段内每天的r1和add_r并把这两个数据统计在一张表上,请问该怎么做啊?另外,周末的日期不要。
*%let date_str = '20140312';
proc sql;
connect to oracle as conname (&risk);
create table hthg as select * from connection to conname
(
select bizdate,a.code,a.name,close_price,bizdate2,close_price2,close_price/close_price2-1 as r,
to_date(bizdate,'yyyy-mm-dd')-to_date(bizdate2,'yyyy-mm-dd') as interval from
(select bizdate,code,name,close_price
from pf_all_quotation
where typecode = 'S'
and code in
('s3756108','h11009')
and bizdate = &date_str ) a
left join (
select bizdate as bizdate2,code,name,close_price as close_price2
from pf_all_quotation
where typecode = 'S'
and code in ('s3756108','h11009')
and bizdate = 20140312 ) b on a.code=b.code
);
disconnect from conname;
quit;
%let a='R0000056';
data hthg2;
set hthg;
if code='s3756108' then
do;
r1=0.5*r;
p=&a;
end;
if code='h11009' then
do;
r1=0.5*r;
p=&a;
end;
run;
proc sql;
create table hthg3 as
( select sum(r1)as r,p,bizdate
from hthg2
where p=&a
group by p,bizdate
);
quit;
proc sql;
connect to oracle as conname (&risk);
create table jingzhi_hthg as select * from connection to conname
(
select c.*,b2,nav2,add2 from
(select a.painnercode as p, panamecn, bizdate, nav, addupnav as add1
from pd_real_pa_netval a
left join pd_pa_definition b on a.painnercode = b.painnercode
where bizdate = &date_str
and a.painnercode ='R0000056' ) c
left join
( select painnercode as p,bizdate as b2, nav as nav2, addupnav as add2
from pd_real_pa_netval
where bizdate = 20140312
and painnercode ='R0000056' ) d on c.p=d.p
);
disconnect from conname;
quit;
data jingzhi_hthg;
set jingzhi_hthg;
add_r=(add1-add2)/nav2; * 修正复权净值增长率;
drop b2 nav2 add2;
run;
data pf_all_bench17; * 业绩基准表 03.11运作;
merge jingzhi_hthg hthg3;
by p;
run;