Hello Guys,
I'm trying to merge two tables by cusip number and date, there are no empty values in every column, but the merged table has empty columns, what are the possible reasons?
Thank YOU
proc sql;
create table aa
as select a.*, b.*
from temp04 as a
left join temp05 as b
on a.cusip=b.cusip and a.datadate=b.date;
quit;
proc sql;
create table aa
as select a.*, b.*
from temp04 as a,
temp05 as b
where a.cusip=b.cusip and a.datadate=b.date;
quit;
Thank you for your reply, but i need temp04 left join temp05.
With a left join, this just means there are some mismatches ... CUSIPs and/or dates that appear in temp04 but don't appear in temp05.
Inspecting the data you posted, it looks like there would be plenty of mismatches. The result you have is not surprising. You need an exact match on both CUSIP and DATE.
Yes, because i only need the data in temp04, temp05 is all 20-year daily data. My result shows the whole column is empty
When you have two tables with the same variable name and you use Select a.*, b.* the value of the common named variable may not be coming from the table you expect.
Try using this select and see if it helps:
Select a.cusip as cusipA, b.cusip as cusipB, a.*, b.*
Is the format for CUSIPs the same in both datasets? It seems to have 9 characters with leading zeros in temp04 and 8 characters without leading zeros in temp05.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.