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]

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!

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.

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