DATA Step, Macro, Functions and more

Proc compare - controlling output with multiple runs

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 145
Accepted Solution

Proc compare - controlling output with multiple runs

[ Edited ]

Dear All,

 

Can some one help me with below issue.

 

I comparing the around 100 datasets in the two libraries by using the Proc compare. 98% of datasets have similar attributes and are identical. when i am running proc compare by having 100 datasets in the 'Do LOOP'. I am getting huge report as there 98% of datasets have been compared..."I would like to see in the output only thoose datasets which have unequal values."I have used the option OUTNOEQUAL but it is meant for outputting to Datasets....

 

Thanks

 

Rakesh


Accepted Solutions
Solution
‎07-14-2016 11:18 AM
PROC Star
Posts: 1,233

Re: Proc compare - controlling output with multiple runs

I'm not quite understanding what you are looking for.  Are you saying you want to run PROC COMPARE, and have it produce NO output if the two datasets match?  For that, you might consider a macro solution that is something like:

 

1. Turn off wrting of output (with proc printto/ ODS Close etc).

2. Run PROC COMPARE

3. Check the value of PROC COMPARE macro variable holding return code, SYSINFO.

4. If SYSINFO is non-zero (so datasets did not match), turn on writing of the output and run PROC COMPARE again.

 

There is a lot on information in SYSINFO that allows you to identify what differences were encountered.

 

View solution in original post


All Replies
Super User
Super User
Posts: 7,407

Re: SAS QUERY

Proc compare is ok.  Personally if I was doing any major comparisons like that I wouold write the code myself to exactly output the results I want.  If you use SQL you can use the except function:

proc sql; 
  create table LEFT as select * from BASE except select * from COMP;
  create table RIGHT as select * from COMP except select * from BASE;
quit;

That will give you the differences betwen the datasets both ways.  You can advance that in many ways of course using merging and such like.

Super User
Posts: 5,085

Re: Proc compare - controlling output with multiple runs

[ Edited ]

You mention that you create a data set with OUTNOEQUAL.  Is the contents of that data set what  you would like to see (without having to view the rest of the output)?

 

It's easy enough to print a SAS data set.  PROC PRINT would do it (perhaps with a VAR statement to control which variables print).  There are two further tasks required.  First, put a title on the PROC PRINT so you can tell which data sets are being compared.  Second, use PROC PRINTTO to move the output to another file that you specify:

 

proc printto print='some other file';

run;

proc print;

run;

proc printto;

run;

 

The final PROC PRINTTO makes sure that the rest of the output that you don't want to see goes to the .lst file.

Frequent Contributor
Posts: 145

Re: Proc compare - controlling output with multiple runs

Hi,

 

I was able to create a dataset and use the proc print option but would like to know if we have an option to suppress the output for only Unequal values. in that way the default proc compare listing remains intact.

Super User
Posts: 5,085

Re: Proc compare - controlling output with multiple runs

There are a ton of options available on the PROC COMPARE statement.  You may need to play with them to figure out which does what you want.  A couple of possibilities

 

BRIEF

NOVALUES

 

Look through the documentation and see what looks promising.

 

http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n0c1y14wyd3u7yn1dmfcp...

 

Solution
‎07-14-2016 11:18 AM
PROC Star
Posts: 1,233

Re: Proc compare - controlling output with multiple runs

I'm not quite understanding what you are looking for.  Are you saying you want to run PROC COMPARE, and have it produce NO output if the two datasets match?  For that, you might consider a macro solution that is something like:

 

1. Turn off wrting of output (with proc printto/ ODS Close etc).

2. Run PROC COMPARE

3. Check the value of PROC COMPARE macro variable holding return code, SYSINFO.

4. If SYSINFO is non-zero (so datasets did not match), turn on writing of the output and run PROC COMPARE again.

 

There is a lot on information in SYSINFO that allows you to identify what differences were encountered.

 

Frequent Contributor
Posts: 145

Re: Proc compare - controlling output with multiple runs

Perfect sir...Thank you..

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 375 views
  • 1 like
  • 4 in conversation