SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1226 views
  • 0 likes
  • 2 in conversation