data a;
input id a b c;
cards;
1 1.1 1.2 1.3
2 2.1 2.2 2.3
3 3.1 3.2 3.3
;
run;
data b;
input idx abc bcd cde def efg fgh;
cards;
1 1.1 1.2 1.3 1.4 1.5 1.6
2 2.1 2.2 2.3 2.4 2.5 2.6
3 3.1 3.2 3.3 2.4 2.5 2.6
;
run;
for example:
a compare with abc
a compare with bcd
a compare with cde
how can i compare see the matching and nonmatching data.
data want;
merge a (keep=a)
b (keep=abc bcd cde); * can adjust or drop desired variables here) ;
run;
Is that what you're looking for? You can then create flags from here.
compare every variable in one data set with available variables in other data set.
data have1; informat x1-x5 $8.; input R x1-x5; cards; 1 12 A B 14 12 2 C X 12 X 5 3 1 1 1 1 1 4 a b c d e 5 a a a a a ; run;
data have2;
informat v1-v5 $8.;
input R v1-v5;
cards;
1 12 d B 14 12
2 C X 12 X 5
3 1 1 1 1 1
4 a c c d e
5 a a b a a ;
run;
proc sort data=have1; by R;run;
proc sort data=have2; by R;run;
data want(drop=count i); merge have1
have2; array _v{*} v:;
array _v{*} v:;
array st{100} $25. ; do i=1 to dim(_v);
do j=1 to dim(_X); if _X{j}=_v{i} then st{i}="Match";else St{i}="Non Match";
end;
end; run;
i am able to compare have1 dataset 1st column with have2 dataset with 1st column..
like same its comparing 2nd to 2nd.
but i need to see between 1st dataset column with all in 2nd dataset.
@krishnaalla wrote:
i am able to compare have1 dataset 1st column with have2 dataset with 1st column..
like same its comparing 2nd to 2nd.
but i need to see between 1st dataset column with all in 2nd dataset.
You really need to show a worked example.
There are quite a few issues that may popup.
You say "with all in 2nd dataset". Do you have a mix of character and numeric variables? What sort of comparison is to be done if one variable is character and the other numeric?
If one data set has 4 variables and the other has 5 are you intending to create 20 new variables to hold the results of the comparison? How should the new variables be named? Are the names supposed to be automagically created by the code? So how many variables are actually involved?
And what sort of value do you actually expect for a comparison?
What type of comparison? Equality, one greater than the other, within or out of a limit of difference, missing and not missing?
And really what the output of your comparison looks like.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.