BookmarkSubscribeRSS Feed
Emnaa61
Calcite | Level 5

Hello everyone,
Sorry for my English, I'm not very good.
I have a program to create and as I'm a beginner I don't know how to do it, the goal is to compare two libraries that are supposed to be exactly the same, and see if there are any differences in the tables.

Should I use a proc content ? A proc compare ? Can we use a compare proc on a whole library ?

4 REPLIES 4
LinusH
Tourmaline | Level 20

No problem, I think I understand!

PROC COMPARE is the tool.

But it handles only one pair of data sets at the time.

The documentation for reference:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0c1y14wyd3u7yn1dmfcpaejllsn.htm

 

Data never sleeps
Emnaa61
Calcite | Level 5

Thanks for your answer Linus
I started to do this, but each librairy contains about 300 data sets

I was looking for a solution to do everything at once, but I didn't find anything, I don't think it's possible...

ballardw
Super User

@Emnaa61 wrote:

Thanks for your answer Linus
I started to do this, but each librairy contains about 300 data sets

I was looking for a solution to do everything at once, but I didn't find anything, I don't think it's possible...


What do you do when there is some difference found?

 

I would start with looking for common data sets to identify the ones that are not common, if any. Then do what you intend for those cases. One way:

proc tabulate data=sashelp.vtable;
   where libname in ('FIRSTLIB' 'OTHERLIB');
   class libname memname;
   table memname,
         libname*n=' '       
   ;
run;

The above uses the SAS metadata view that contains all the library memname (data set or data view ) in your current session. Place the names of your libraries in the where clause in upper case as that is how the values are stored. The table generated will have a 1 to count the number of occurences of the data set name within the library. The data sets (or views) will be in the rows.

 

You can also examine presence of variables by data set/library.

One way:

proc tabulate data=sashelp.vcolumn;
   where libname in ('FIRSTLIB' 'OTHERLIB');
   class libname memname name type;
   table memname,
         name*type,
         libname*n=' '
   ;
run;

This uses the information about variables. The specific layout will have one report table for each membername value, row headers will be the variable name and variable type(if you have both numeric and character that is a problem) and presence by library.

 

I would only run Proc Compare on data sets where the variable names and types match for the same named data sets in both libraries. Differences of missing variables or different types means that you go directly to your procedure for dealing with seriously different data.

 

Exercise for the interested reader: Apply the similar approach to the SASHELP.VTABLE view to check on other data set properties such as nobs, number of observations, and such.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1850 views
  • 2 likes
  • 4 in conversation