Hello!
I have two sas tables and am trying figure out which observations between the two tables are different.
I don't know if table a has observations table b doesn't have and vice versa.
How would I do that? They differ by the identifying variable schcode
proc sql;
create table differing as
select a.*
from a
left join b on a.schcode=b.schcode;
quit;
Thanks!
Are you simply trying to see which observations are in one and and not in the other? If so, then this would work:
proc sql;
create table differing as
select *, 'In A, not in B' as Note
from a
where schcode not in (select schcode from b)
union
select *, 'In B, not in A' as Note
from b
where schcode not in (select schcode from a);
quit;
If you're trying to column compare values as well, then proc compare is the way to go.
Take a look at PROC COMPARE. It's an excellent option for comparing observations between two SAS data sets.
Are you simply trying to see which observations are in one and and not in the other? If so, then this would work:
proc sql;
create table differing as
select *, 'In A, not in B' as Note
from a
where schcode not in (select schcode from b)
union
select *, 'In B, not in A' as Note
from b
where schcode not in (select schcode from a);
quit;
If you're trying to column compare values as well, then proc compare is the way to go.
Thank you everyone :)!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.