BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am comparing two datasets that have the same variables. The variables are "id", "insdate" & "ins" for the two insurance tables. The compare works great but I want the ouptut to show which "id" has the issue. Currently the output only shows which "OBS" (record number). There are multiple records in the datasets, therefore 'id" variable is not unique. Here's my code:

*compare datasets;
%macro compare (a,b);
proc compare base=&a compare=&b;
run;
%mend compare;

%compare (hpv1_insurance,hpv2_insurance);
%compare (hpv1_papsmear,hpv2_papsmear);
run;

Thanks,
Wal
2 REPLIES 2
Anitha_SAS
SAS Employee
Try with the option 'outall'

Example:

*compare datasets;
%macro compare (a,b,c);
proc compare base=&a compare=&b out=&c outall noprint;
run;
proc print data=&c;
title 'An OUT= Data Set';
run;
%mend compare;

%compare (hpv1_insurance,hpv2_insurance,tempout1);
%compare (hpv1_papsmear,hpv2_papsmear,tempout2);
run;
deleted_user
Not applicable
Thanks for the input. I ended up writing the below code before I saw your comment and it worked fairly well. It gave me a printout of only observations with errors. If I need a dataset your code would be the choice. Thanks again.

%macro compare (a,b,c);
proc compare base=&a compare=&b nosummary;
by id;
run;
%mend compare;

%compare (hpv1_insurance,hpv2_insurance);
%compare (hpv1_papsmear,hpv2_papsmear);
run;

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
  • 2 replies
  • 693 views
  • 0 likes
  • 2 in conversation