BookmarkSubscribeRSS Feed
nithya_r99
Calcite | Level 5

I am trying to create a proc compare that will have two outputs.  One will give the output for diffs between variables between two data sets and one will be comparing the actual contents of the two data sets.  Is there a way I can do this in a single proc compare>

7 REPLIES 7
ballardw
Super User

What do you mean by " actual contents of the two data sets?"

 

One of the summaries that proc compare does is number and types of variables, number of records, difference between like named variables of properties such as label, format and type.

The first example in the documentation shows this sort of summary:

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=proc&docsetTarget=p1k00d4...

 

 

For best results with Proc compare sort both data sets first to make things a similar as possible. Then provide the sort order in a BY statement.

nithya_r99
Calcite | Level 5
So what I want is one output that gives any differences between the variables themselves and then one that gives line by line differences. I know that this is what proc compare does, but is there a way that I could send those specific outputs to two Different output destinations?
ballardw
Super User

Please look at the documentation and experiment.

 

Proc compare is very old and doesn't really do "destinations" very well. Create data sets with the desired output and send them to different "destinations".

 

There are a lot of options and they interact quite a bit. So without knowing exactly what you expect for given input I would be guessing. You may need to take more than one pass depending on what specifically you are looking for. You may be looking in the detail bit for a combination of OUT= with the OUTDIF and OUTNOEQUAL for "only not equal" type of comparison.

 

Reeza
Super User

Run it twice with different ODS SELECT for each destination?
Or pipe to output data set using ODS OUTPUT and then pipe to the output destination of choice.
Or try using ODS <destination> select ... to control the destination. If they're the same type (ie multiple PDF or HTML use the ID option instead)

ods html file='/home/fkhurshed/Demo1/testODS1.html';
ods pdf file='/home/fkhurshed/Demo1/testODS2.pdf';

ods html select BasicMeasures;
ods pdf select Quantiles;
proc univariate data=sashelp.class;
run;


ods html close;
ods pdf close;

@nithya_r99 wrote:
So what I want is one output that gives any differences between the variables themselves and then one that gives line by line differences. I know that this is what proc compare does, but is there a way that I could send those specific outputs to two Different output destinations?



Reeza
Super User
Table names are listed here:
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=proc&docsetTarget=n1jbbrf...

I'll second what others have said though, I find PROC COMPARE rarely meets my needs and often end up rolling my own to get what I need.
It needs some significant enhancements as it could be quite a powerful procedure but the reality is that's it's also very easy to replicate with basic code.
SASKiwi
PROC Star

I find COMPARE is best for checking "high-level" dataset differences - that is summarising what is different like the number of rows and variables and the number of differences between variables. It doesn't do actual data difference in an output dataset well, so you are better off doing that separately in a DATA step or SQL.

 

I agree with @Reeza that COMPARE is showing it's age and could do with some serious enhancement. However I still use it daily to quickly give me a high-level view of dataset differences.

ballardw
Super User

I wonder if when Proc Compare was first written if any of programmers thought they would have to deal with data sets containing 10,000 variables like some of the questions on this forum bring up.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 574 views
  • 2 likes
  • 4 in conversation