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
Please explain in detail the environment you are using. With Enterprise Guide it is impossible to display message boxes, same for SAS Studio.
I am using Enterprise Guide on SAS server. Thank you!
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.
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!
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?
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
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
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
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.