上市公司的年报最晚4月底发布;半年报最晚8月底发布,数据库中报告期都是6月底和12月底。
为了模拟真实的环境,需要在取某天的财务数据时,进行修改日期以便于在Sql中调用。
比如
2011-1-31 ,修改为 2010-6-30;2011-5-12,修改为 2010-12-31;2011-10-12,修改为 2011-6-30;
如何利用SAS宏实现这个转换呢?我试了很久,总是报错:
ERROR: 需要的操作符在以下表达式中没有找到: &Dmonth <= 4
请高手指点:
%macro WindFetch2(chkDate);
/*Below is Financial indicators 1158*/
%let Dyear = substr(&chkDate,1,4);
%let Dmonth = input(substr(&chkDate,5,2),2.);
%if &Dmonth <= 4 %then %let dd=(&dyear-1)!!'0630';
%else %if &Dmonth <= 8 %then %let dd=(&dyear-1)!!'1231';
%else %let dd= &dyear !!'0630';
proc sql;
create table b as
select b.F4_1158,b.F5_1158,b.F3_1158,b.F9_1158
from wind.tb_object_1090 as a,wind.tb_object_1158 as b
where a.OB_REVISIONS_1090=b.F1_1158 and a.F4_1090='A'
and a.F16_1090='000002' and b.F3_1158=&dd
order by b.F3_1158;
quit;
%mend;
%WindFetch2('20110131')