BookmarkSubscribeRSS Feed
spg
Obsidian | Level 7 spg
Obsidian | Level 7
Can I use proc compare to compare and output equal values in more than two columns in the same dataset? Say for the following, each class has different combinations of different columns for weight, but I want them all extracted from the bigger dataset:

Class Wt1 Wt2 Wt3 Wt4 Wt5

1 67 89 56 56 45
2 72 72 45 87 23
3 43 78 99 43 88


Thanks!
1 REPLY 1
data_null__
Jade | Level 19
I'm not sure what output you want.

Assuming I know what you want it can be done with COMPARE but is probably easier using an (array do etc.).

Here is my take on proc compare. You probably would want some code to gen the VAR/WITH statements which gets us back to (array do etc.).

[pre]
data Wt;
input Class Wt1-Wt5;
cards;
1 67 89 56 56 45
2 72 72 45 87 23
3 43 78 99 43 88
;;;;
run;
proc compare data=wt noprint outstat=stat(where=(_type_ eq 'NDIF' and _BASE_ eq 0));
by class;
var wt1 wt1 wt1 wt1 wt2 wt2 wt2 wt3 wt3 wt4;
with wt2-wt5 wt3-wt5 wt4-wt5 wt5;
run;
proc print;
run;

Obs Class _VAR_ _WITH_ _TYPE_ _BASE_ _COMP_ _DIF_ _PCTDIF_

1 1 Wt3 Wt4 NDIF 0 0 . .
2 2 Wt1 Wt2 NDIF 0 0 . .
3 3 Wt1 Wt4 NDIF 0 0
. .
[/pre]

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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