SQL左JOIN与Werra Sas Enterprise指南
我试图在其ID字段上配对2个表(昵称为Persip和ecif)(标记为Table1& Table2)来创建一个可效果,其中ym_id(对于两个表)变量设置为我的TimeKey0变量,以用于特定数据周期。
我想知道为什么此代码会产生0行结果数据。在网上查找之后,这是人们发布的格式作为解决类似问题的解决方案。
%let timekey0 = 202110;
proc sql;
CREATE TABLE RESULTTABLE AS
SELECT
PERSIP.col1,
PERSIP.col2,
PERSIP.col3,
ECIF.col1,
ECIF.col2,
ECIF.col3,
ECIF.col4
FROM DB.TABLE1 PERSIP
LEFT JOIN DB.TABLE2 ECIF
ON PERSIP.ID = ECIF.ID
WHERE ECIF.ym_id = &timekey0.
AND PERSIP.ym_id = &timekey0.;
quit;
我得到了0行的结果,其中有许多列。不确定我的联接类型是否不正确,但表中有0行。
I am trying to pair 2 tables (nicknamed PERSIP and ECIF) on their ID field, (labeled TABLE1 & TABLE2) to create a RESULTTABLE, where the ym_id (for both tables) variable is set to my timekey0 variable for a specific datetime.
I am wondering why this code produces 0 rows of resulting data. After looking online, this was the format people posted as solutions to similar problems.
%let timekey0 = 202110;
proc sql;
CREATE TABLE RESULTTABLE AS
SELECT
PERSIP.col1,
PERSIP.col2,
PERSIP.col3,
ECIF.col1,
ECIF.col2,
ECIF.col3,
ECIF.col4
FROM DB.TABLE1 PERSIP
LEFT JOIN DB.TABLE2 ECIF
ON PERSIP.ID = ECIF.ID
WHERE ECIF.ym_id = &timekey0.
AND PERSIP.ym_id = &timekey0.;
quit;
I got a result of 0 rows with many columns. Not sure if my join type is incorrect but I have 0 rows in the table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
造成这种情况的原因可能有两个:
=& timeKey0。
There may be two reasons for this:
AND PERSIP.ym_id = &timekey0.)
您的逻辑似乎消失了。您说您想要一个左联接,然后在您的条件下使用“右”表中的变量。
您很可能只想将这些条件添加到状态。
或者也许只是保持条件,以限制从“左”表中读取的观察结果
Your logic seems off. You say you want a LEFT JOIN then use a variable from the "RIGHT" table in your WHERE condition.
Most likely you just want to add those conditions to the ON condition.
Or perhaps just keep the condition that will limit the observations read from the "LEFT" table in the WHERE condition