BookmarkSubscribeRSS Feed
Zatere
Quartz | Level 8

Hi,

 

I am looking for an alternative method to get the results you get when using PROC COMPARE. I ve got a dataset which has columns representing values from two different years. For example, Total_Value_Y1 and Total_Value_Y2, Total_Quantity_Y1 and Total_Quantity_Y2 and so on. 

 

I want to get the difference of the pairs of the numeric columns and indication when the columns are character.

 

Below a sample code for illustration:

 

data class2;
set sashelp.class;

if age=12 then weight1=50; else weight1 = weight;
if age=12 then sex1='K'; else sex1 = sex;
if age=12 then height1=60; else height1 = height;
run;

proc compare data=class2 out=check  ;
by name;
var weight height sex;
with weight1 height1 sex1;
run;

When the dataset is large it takes a long time to run. Is there a more efficient way to get the same rerults?

 

Thanks!

1 REPLY 1
SASKiwi
PROC Star

I use PROC COMPARE a lot and find it reasonably efficient for comparing large datasets. It does get slower the more differences there are, but that would be the same regardless of what method you use. Put it this way in my experience it is not a lot slower than creating the datasets being compared in the first place.

 

As an alternative I would suggest trying PROC SQL. If there are a lot of differences in your data then it could be more efficient. 

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
  • 1 reply
  • 992 views
  • 0 likes
  • 2 in conversation