如何解决{SAS} 将 SQL 合并转换为 HASH 合并
proc sql;
create table ndd1 as
select a.*,1 as default_flag,b.retail_account_no,c.limit
from (
select
posting_date,counterparty_id,counterparty_indicator,customer_id,last_default_date,last_out_of_default_date
from gdwh30.tb0_default
where counterparty_id<>'*noval*'
and ((last_out_of_default_date < posting_date and last_default_date >= last_out_of_default_date)
or (last_out_of_default_date > posting_date and last_default_date < last_out_of_default_date))
and posting_date = to_date(%nrbquote(')&tt.%nrbquote('),'DD-MON-YYYY hh24:mi')) a
left join (
select retail_account_no,REF_account_ID,regexp_substr(REF_account_ID,'[^*]+',1) as counterparty_id
from gdwh30.TB0_account
/*tb_account*/
where bus_date_from<= to_date(%nrbquote(')&tt.%nrbquote('),'DD-MON-YYYY hh24:mi')
and bus_date_until>=to_date(%nrbquote(')&tt.%nrbquote('),'DD-MON-YYYY hh24:mi')
and entity_id='RBBG') b
on a.counterparty_id=b.counterparty_id
;quit;
&tt。是形式
30APR2020:00:00:00
或 date22。
data ndd_1;
if 0 then set gdwh30.tb0_default today ;
if _n_=1 then do;
declare hash k(dataset:"gdwh30.tb0_default");
k.definekey ("posting_date");
k.definedata ("counterparty_id","posting_date","last_out_of_default_date","last_default_date");
k.definedone();
declare hash j(dataset:"today");
j.definekey("today1");
j.definedata ("today1");
j.definedone();
end;
set ndd_1;
if k.find(key:posting_date)=0 and j.find(key:today1)=0 then output;
run;
我认为必须做的是将列格式化为 N=1;
对于 Tb0_acc 上的第二次连接,我想尝试进行模糊合并,因此将不胜感激。
今天是 &tt。但在表格而不是列表中。我首先尝试加入 A 部分只是为了感受一下这些散列连接。
Posting_date 的格式为 31AUG2016:00:00:00
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。