11-01-2017 11:03 AM
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;
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.
11-01-2017 11:14 AM
Please explain in detail the environment you are using. With Enterprise Guide it is impossible to display message boxes, same for SAS Studio.
11-01-2017 11:14 AM
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.
11-01-2017 11:48 AM
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.
11-01-2017 12:16 PM
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:
Not that familiar with EG, maybe there is already a task to do email from step?
11-01-2017 02:01 PM
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.
11-01-2017 12:40 PM - edited 11-01-2017 12:41 PM
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
11-01-2017 05:12 PM
You can use the ODS OUTPUT data sets from COMPARE and parse the content. This circumvents parsing the logs.
ods output comparesummary=compsummary;
proc compare base=libref1.dsname compare=libref2.dsname; run;
where batch like '%Number of Observations with Some Compared Variables Unequal:%';
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.