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.

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at 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.

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
rakeshvvv
Quartz | Level 8

Perfect sir...Thank you..

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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