BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FabeehaSheikh1
Fluorite | Level 6

I want to compare 2 datasets without using proc compare procedure. How to do that?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@FabeehaSheikh1 wrote:

nothing wrong with proc compare. This was one of the interview questions. I want to compare all variables and values it contains in the dataset without using proc compare. Hence, this question.


In an interview question my response would start with the "what do you want to know" from the comparison.

Some of the table properties are in Dictionary.tables for Proc SQL (or sashelp.vtables for other procs).

Variable properties in Dictionary.columns or sashelp.vcolumns .

Value comparisons get into, most likely some form of Proc SQL or Data step merge/update/modify or similar,l depending on the actual questions about the values. Big difference in approaches of if the question involves equality of values, specific combinations of values or something like how close are the values such as comparing the results of two different models where you "know" the values of the predicted variable(s) are likely to differ but by how much. (Which might well be doable inside the modeling proc if careful).

 

No reason to go into a lot of code for other things that aren't needed/wanted to answer specific questions.

View solution in original post

4 REPLIES 4
ballardw
Super User

Depends on what you want to find out about the two data  sets. Properties of the data set such as number of observations, numbers of variables. Or about variables such as common or different variables or different characteristics for same named variables? Or values/ combinations of values ?

 

And what is wrong with proc compare? I know there are things we may want to do that compare doesn't do, or not easily, but

FabeehaSheikh1
Fluorite | Level 6

nothing wrong with proc compare. This was one of the interview questions. I want to compare all variables and values it contains in the dataset without using proc compare. Hence, this question.

ballardw
Super User

@FabeehaSheikh1 wrote:

nothing wrong with proc compare. This was one of the interview questions. I want to compare all variables and values it contains in the dataset without using proc compare. Hence, this question.


In an interview question my response would start with the "what do you want to know" from the comparison.

Some of the table properties are in Dictionary.tables for Proc SQL (or sashelp.vtables for other procs).

Variable properties in Dictionary.columns or sashelp.vcolumns .

Value comparisons get into, most likely some form of Proc SQL or Data step merge/update/modify or similar,l depending on the actual questions about the values. Big difference in approaches of if the question involves equality of values, specific combinations of values or something like how close are the values such as comparing the results of two different models where you "know" the values of the predicted variable(s) are likely to differ but by how much. (Which might well be doable inside the modeling proc if careful).

 

No reason to go into a lot of code for other things that aren't needed/wanted to answer specific questions.

aayo
Obsidian | Level 7

Hi Fabeeha,

check this.

 

proc sql;

create table mismatch as
select * from tableA
where ID not in (select ID from tableB );
quit;

 

N.B: ID is the unique identifier you want to use to compare

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 860 views
  • 0 likes
  • 3 in conversation