SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

automatically output "Proc compare" result?

Reply
Regular Contributor
Posts: 223

automatically output "Proc compare" result?

Hi All,

 

    I have a question about automatically outputting the "Proc Compare" result to clients. What I want is to get a message when the tables being compared are different.

    Anyone has any suggestion to do this? Thank you!

 

    Right now I came up with:

   1) get error message if the tables are different. I can get the error message in the log file if using syntax like below:

PROC COMPARE BASE=count_test1 COMPARE=count_test2 ERROR NOPRINT;

RUN;

ERROR: Values of the following 1 variables compare unequal: test

ERROR: The data sets WORK.COUNT_TEST1 and WORK.COUNT_TEST2 contain unequal values.

 

   2) output the error message or log file to clients. I don't know how to proceed on this step.

 

Thank you!

Jade

Regular Contributor
Posts: 202

Re: automatically output "Proc compare" result?

Please explain in detail the environment you are using. With Enterprise Guide it is impossible to display message boxes, same for SAS Studio. 

Regular Contributor
Posts: 223

Re: automatically output "Proc compare" result?

Posted in reply to error_prone

I am using Enterprise Guide on SAS server. Thank you!

Super User
Super User
Posts: 9,407

Re: automatically output "Proc compare" result?

In what sense sorry?  The reason I ask is that unless that proc compare is run as part of an automated import system, I don't see how it can be automatically returned to the client.  If you have an automated import system, i.e. client sends a file to a web portal and then at your end code runs, then you could either return a message via the portal or send them an email.  However if its you running it then you need to send the information back.  Lack of information for anything specific.

Regular Contributor
Posts: 223

Re: automatically output "Proc compare" result?

I am using SAS EG on SAS server.

What I am trying to say is get the "table is different" log file out of SAS EG, then give to the client this message.

Thank you!

Super User
Super User
Posts: 9,407

Re: automatically output "Proc compare" result?

Can you not just email the log out?  Proc print the log to  text file, then do a filename email and datastep, this should help:

http://www2.sas.com/proceedings/forum2008/038-2008.pdf

 

Not that familiar with EG, maybe there is already a task to do email from step?

PROC Star
Posts: 1,288

Re: automatically output "Proc compare" result?

When you say "get the "table is different" log file out of SAS EG, then give to the client this message.", it's a little unclear. Exactly how would you like the message conveyed to the client? Then we can figure out how to get SAS to do it.

 

Tom

Regular Contributor
Posts: 202

Re: automatically output "Proc compare" result?

[ Edited ]

I don't have access to an EG right now, but there should be a task to send the log as mails, like @RW9 said. proc compare sets a macro variable to something > 0 if the datasets are not equal, you just have to define a condition for the mail task, checking the variable. The following document describes the macro variable created by proc compare: https://support.sas.com/resources/papers/proceedings12/063-2012.pdf  

New Contributor
Posts: 2

Re: automatically output "Proc compare" result?

You can use the ODS OUTPUT data sets from COMPARE and parse the content.  This circumvents parsing the logs.  

For example:

 

ods output comparesummary=compsummary;

proc compare base=libref1.dsname compare=libref2.dsname; run;

 

data compcheck;

   set compsummary;

   where batch like '%Number of Observations with Some Compared Variables Unequal:%';

   unequal=strip(compress(scan(batch,-1,":"),"."));

run;

ods output close;

 

You can clean up the code to meet your needs or parse out what you want from compsummary.  

In the SAS Documentation you will see four other data sets that you can create from COMPARE.

Hope this helps.

Cheers

Ask a Question
Discussion stats
  • 8 replies
  • 299 views
  • 0 likes
  • 5 in conversation