|
|
Re: 请教一个从两个表提取数据的问题
[quote:outjqvuh]由 ganshenme » 2011年 4月 2日 周六 3:59 pm
多谢,程序虽然复杂一点,但是管用,问题是第一个left join会导致数据量奇大无比 [/quote:outjqvuh]
不生成vtemp
%macro a(yymmdd,id,company,lag=3);
proc sql;
create table v1 as select *
from a where &yymmdd. -10<= date< &yymmdd. and id="&id"
order by date descending;
create table v2 as select *
from a where &yymmdd.+10 >= date> &yymmdd. and id="&id"
order by date ascending ;
create table v3 as select *
from a where date= &yymmdd. and id="&id" ;
quit;
data vv_final ;
set vv_final(in=a) v1(obs=&lag.) v3(obs=1) v2 (obs=&lag.) ;
if not a then campany="&company.";
run;
%mend a;
data vv_final;
set a(obs=0);
data _null_;
set b ;
call execute('%a('||date||','||id||','||company||');');
call execute('run;');
run; |
|