data t1;
input id1 $3. id2 $5.;
cards;
123 hkg5
689 yukq
567 khnx
;
run;
data t2;
input id1 $3. id2 $5.;
cards;
123 hkg5
569 yukq
567 khnt
;
run;
I want to get mis-matched records from t1 and t2 where the id1 is different in two tables for id2 values, In the above example I just want to retrieve 567 khnt
what is the best way to compare two columns from two tables?
trying to replicate the following query that is working fine in other application..
select t1.custid,t2.custid,t2.id2,ord_date from t2 left join t1 using(id2)where t2.custid != t1.custid
Thank you
@Stalk wrote:
...
I want to get mis-matched records from t1 and t2 where the id1 is different in two tables for id2 values, In the above example I just want to retrieve 567 khnt
Based on the sample data you've provided the only matching row over ID2 that has different values for ID1 is as below:
proc sql;
select
t1.id1,
t2.id1,
t2.id2
from t2 inner join t1
on t2.id2=t1.id2
where t2.id1 ne t1.id1
;
quit;
What am I missing?
@Stalk wrote:
...
I want to get mis-matched records from t1 and t2 where the id1 is different in two tables for id2 values, In the above example I just want to retrieve 567 khnt
Based on the sample data you've provided the only matching row over ID2 that has different values for ID1 is as below:
proc sql;
select
t1.id1,
t2.id1,
t2.id2
from t2 inner join t1
on t2.id2=t1.id2
where t2.id1 ne t1.id1
;
quit;
What am I missing?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.