BookmarkSubscribeRSS Feed
krishnaalla
Fluorite | Level 6

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. 

9 REPLIES 9
maguiremq
SAS Super FREQ
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.

krishnaalla
Fluorite | Level 6
I need to see the match data all variable in one table with available
variables in another table
krishnaalla
Fluorite | Level 6

compare every variable in one data set  with available variables in other data set.

Reeza
Super User
Given the above data, what do you want as output?
krishnaalla
Fluorite | Level 6

 

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;

 

krishnaalla
Fluorite | Level 6

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.    

ballardw
Super User

@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?

ballardw
Super User

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.

Haris
Lapis Lazuli | Level 10
```proc compare base=a comp=b(rename=(IDx=ID));
var a a a;
with abc bcd cde;
id ID;
run;
```

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 9 replies
  • 1310 views
  • 0 likes
  • 5 in conversation