简体   繁体   中英

SQL/SAS many repeat records with JOIN

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 在此处输入图像描述

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;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM