Help using Base SAS procedures

proc compare

Reply
Contributor spg
Contributor
Posts: 61

proc compare

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!
Respected Advisor
Posts: 3,777

Re: proc compare

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]
Ask a Question
Discussion stats
  • 1 reply
  • 144 views
  • 0 likes
  • 2 in conversation