您好:擅长SAS的人请将此SQL转换为DATA步骤:
create table tableD nologging as
select
a.acct,
b.app_dt,
case when a.acct in (select acct from tableC) then 1 else 0 end prom_ind
from tableA a
inner join tableB b
on a.application_no = b.application_no
where to_char(b.app_dt,'yyyymmdd') between '20150101' and '20150630' ;
quit;
答案 0 :(得分:1)
粗暴的尝试,未经测试,因为没有数据等。
首先合并并加入应用程序编号,然后在另一步骤中添加标志。或者您可以修改SQL以在PROC SQL中工作,这是一个简单的练习。
data part1;
merge tableA (in=A) tableB(in=B where=(appt_dt between '01Jan2015'd and '30Jun2015'd );
by application_no;
if a and b;
keep acct app_dt application_no;
run;
data part2;
merge part1 (in=p1) tableC (in=C);
by acc;
if p1;
if p1 and C then prom_ind=1;
else prom_ind=0;
run;
SAS SQL:
proc sql;
create table tableD nologging as
select
a.acct,
b.app_dt,
case when a.acct in (select acct from tableC) then 1 else 0 end prom_ind
from tableA a
inner join tableB b
on a.application_no = b.application_no
where b.app_dt between '01Jan2015'd and '30Jun2015'd ;
quit;