PROC SQL 左连接 ID 和日期不起作用

问题描述 投票:0回答:1

我正在尝试使用以下代码合并两个表:

proc sql;
create table test as
select a.*, b.*
from aaa a
left join bbb b on a.id=b.id and a.date1<=b.date2;
quit;

但是输出显示表中的列中存在空白

b

但是,如果我将其更改为

a.date1>=b.date2
,它似乎可以工作。为什么会出现这种情况?

我已进行检查以确保:1)日期格式正确; 2) 表

aaa
中的日期比表
b
日期少或多。 请帮忙!

date merge proc-sql
1个回答
0
投票
proc sql;
create table test as
select a.*, b.*
from aaa a
left join bbb b on a.id=b.id and datepart(a.date1)<=datepart(b.date2);
quit;

好吧,看起来当我将日期部分添加到两个日期时,它工作得很好。希望这对某人有用。

© www.soinside.com 2019 - 2024. All rights reserved.