BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rakeshvvv
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

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.

 

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Astounding
PROC Star

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.

rakeshvvv
Quartz | Level 8

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.

Astounding
PROC Star

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...

 

Quentin
Super User

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.

 

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
rakeshvvv
Quartz | Level 8

Perfect sir...Thank you..

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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