SQL/SAS许多重复记录,并加入

发布于 2025-01-24 07:45:18 字数 771 浏览 1 评论 0原文

我有两个表,我想组合它们,以便每个带有交易日期的ISIN项目都会从第二个表中添加适当的值。但是,如图所示,它向我显示了每个项目添加相同值的结果,我希望它们不可重复。如何连接或修复此错误。

DBMS:SAS

PROC SQL;
create table Instrumenty_2 as
select 
b.WBIL_BRUTTO_PLN
,b.WYCENA_UJE_PLN
,b.KOD_ISIN 
from bmd.PAP_WART_SPR_&thismonth as b
;
quit;
PROC SQL;
create table Instrumenty_4 as
select 
ISIN_CODE
,TRADE_DATE
,SETTLEMENT_DATE
,MATURITY_DATE
,QUANTITY
,GROSS_AMOUNT
from kondor.k_papiery as a
left join Instrumenty_2 as b
on b.KOD_ISIN = a.ISIN_CODE
where DATA_DANYCH EQ &gv_date.
and TYPE_OF_INSTR_SHORT_NAME = "OBLIGACJE" 
and CPTY_SHORT_NAME = "BAN1"


;
quit;

I have two tables, I would like to combine them so that each ISIN item with transaction date adds the appropriate value from the second table. However, as in the picture, it shows me the results where the same value is added to each item, I would like them to be non-repeatable. How to connect or fix this error.

DBMS : SAS
enter image description here

PROC SQL;
create table Instrumenty_2 as
select 
b.WBIL_BRUTTO_PLN
,b.WYCENA_UJE_PLN
,b.KOD_ISIN 
from bmd.PAP_WART_SPR_&thismonth as b
;
quit;
PROC SQL;
create table Instrumenty_4 as
select 
ISIN_CODE
,TRADE_DATE
,SETTLEMENT_DATE
,MATURITY_DATE
,QUANTITY
,GROSS_AMOUNT
from kondor.k_papiery as a
left join Instrumenty_2 as b
on b.KOD_ISIN = a.ISIN_CODE
where DATA_DANYCH EQ &gv_date.
and TYPE_OF_INSTR_SHORT_NAME = "OBLIGACJE" 
and CPTY_SHORT_NAME = "BAN1"


;
quit;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝眼泪 2025-01-31 07:45:18

您的表格中的至少一个有几个条目,这些条目是您使用的变量。 SAS然后以您观察的方式行事。您能做的就是不同以防止双行,但是我认为这无法解决您的问题。您可以做的是尝试使用其他列加入或在两个表上添加一些条件。但是,至少在不了解数据的情况下,提供了一些困难的帮助。

At least one of your table has several entries of the variable you use to join. SAS acts then in the way you observe. What you could do is using distinct to prevent double rows, however I think this will not solve your problem. What you could do is try to join using additional columns or add some conditions on both tables. But without knowing the data, at least with some example, is offering help somewhat difficult.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文