DATA Step, Macro, Functions and more

Easy way to compare

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 144
Accepted Solution

Easy way to compare

Hi everyone and thank you for read it,

Well, I'm trying to do a kind of auto validation. For do these I create a expected output the first time and I

confirm that all is okay.

My first problem appears when I try to use the PROC COMPARE to decide if my validated dataset and me

new dataset are the same. For example, if I compare my base with

data new;

set base

         base;

run;

The proc compare say there are XX line equal and 0 unequal and this is false, there are not the same dataset.

My first question is, Exist any procedure that say you YES/NO to the comparation?
If the answer is NO, there exist any easy way to know if two dataset are exactly the same.

My other question is looking further, I should compare .TXT with other .TXT how can I do it in SAS?

Thanks for the help,

Antonio Rodríguez


Accepted Solutions
Solution
‎02-03-2014 02:54 AM
Frequent Contributor
Posts: 144

Re: Easy way to compare

At last I have found how to do it. There is a option in proc compare to put a warning or an error if there is something diferent. I have activated

this option, then I look the content of SYSERRORTEXT or SYSWARNINGTEXT.

View solution in original post


All Replies
Super User
Posts: 17,784

Re: Easy way to compare

You're looking for a line that says the following I assume:

Number of Observations in WORK.CLASS2 but not in WORK.CLASS: 19.

I agree the note is misleading, but is actually correct. All compared values were the same, but one had obs not in the other, so those are not comapred.

NOTE: No unequal values were found. All values compared are exactly equal.

If you run with the BriefSummary option you get two notes:

NOTE: Data set WORK.CLASS2 contains 19 observations not in WORK.CLASS.

NOTE: No unequal values were found. All values compared are exactly equal.

Or you could use the OUTSTATS= option and verify in a second step.

Frequent Contributor
Posts: 144

Re: Easy way to compare

This solve part of the problem of understand the proc compare, but if I compere two datasets, with the same variables

and the same values and a different format, for example insteed of $5. put $30. there are not the same dataset, but the

proc compare say that are equal.

Super User
Posts: 17,784

Re: Easy way to compare

RTM.

Proc compare will tell you when variables are different, formats, types, attributes etc you just need to look in different places.

Or roll your own.

Base SAS(R) 9.3 Procedures Guide, Second Edition

Solution
‎02-03-2014 02:54 AM
Frequent Contributor
Posts: 144

Re: Easy way to compare

At last I have found how to do it. There is a option in proc compare to put a warning or an error if there is something diferent. I have activated

this option, then I look the content of SYSERRORTEXT or SYSWARNINGTEXT.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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