【发布时间】:2021-12-17 06:38:00
【问题描述】:
我想修改函数代码以减去结果,例如今天的 Run_date 来自上一个。但是,我的观点是它应该只从相同的 POLICY_VIntage 中减去结果,即当前 (rund_date) 2021.01 - 先前 (2021.01)。不像下面的图片,例如 2021.08 - 2021.09 [![在此处输入图片描述][1]][1]
[1]: https://i.stack.imgur.com/T7k8Y.png
proc sql;
create table policy_vintage_weekly as
select
policy_vintage
,count(NRB) as number_policy
,today() as Run_Date format weeku.
from PolisyEnd
where POLIS= "W"
group by policy_vintage
;
quit;
data policy_vintage_weekly_all;
set
_work.policy_vintage_weekly (where=(run_date ne today()))
policy_vintage_weekly
;
by policy_vintage run_date;
run;
%if &syscc. = 0
%then %do;
data _work.policy_vintage_weekly;
set policy_vintage_weekly_all;
by policy_vintage;
diff_value = dif(number_policy);
if not last.policy_vintage then diff_value = .;
run;
%end;
/* print report */
proc print data=_work.policy_vintage_weekly noobs;
var policy_vintage number_policy run_date diff_value;
run;
【问题讨论】: