BookmarkSubscribeRSS Feed
Jade_SAS
Pyrite | Level 9

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

8 REPLIES 8
error_prone
Barite | Level 11

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

Jade_SAS
Pyrite | Level 9

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Jade_SAS
Pyrite | Level 9

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!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

TomKari
Onyx | Level 15

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

error_prone
Barite | Level 11

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  

PrimeMeridian
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 2577 views
  • 0 likes
  • 5 in conversation