I want to compare 2 datasets without using proc compare procedure. How to do that?
@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.
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
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.
@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.
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.