The SAS Output Delivery System and reporting techniques

Find most similar record

Reply
Occasional Contributor
Posts: 19

Find most similar record

Hi - I am somewhat new to SAS, and am trying to determine the best course of action to accomplish my goal.  I have a data set full of records, and I want to be able to pull one record out and compare it to every other record in the data set across each variable.  Then, I'd like to be able to aggregate all the differences in order to find the most similar overall record(s). 

For example, in the data set below, if I choose record A as the base record, I want to be able to compare record A to records B-V across every variable.  Afterwards, I want to be able to say "Records L, R, and V are the most similar overall records to record A".  I'm assuming this will have to be done using a macro to compare COL1 of record A to COL1 of record B, measuring & saving the difference, and then moving onto comparing record A to record C.  But I was hoping there may be a more streamlined way to accomplish this? 

Please let me know any help if possible!!!  Thanks!

GR

DATA test ;

infile datalines delimiter=",";

LENGTH col1 $1.;

input COL1 COL2 COL3 COL4 COL5 COL6;

DATALINES;

A,72.25,79.5,98,0,0

B,74,79.25,98.5,37.5,31.5

C,71,77.75,94.5,40.5,35.5

D,74,75.5,97,35.5,29.5

E,71.5,76.25,98,33.5,29

F,71.25,76,95.5,40,33

G,73.25,81,97.5,37.5,34

H,75.25,79,100.5,34,28.5

I,73.75,76,99,0,0

J,74.5,79.5,100,28.5,26

K,73.5,78.75,98.5,37.5,29

L,71.25,72.75,94.5,36.5,29

M,73.75,79.75,95.5,39.5,34.5

N,75,77,98,0,0

O,73,0,0,0,0

P,71.75,76.25,93,38,32

Q,73.5,80,98.5,40,34.5

R,72.25,79.5,98.5,36.5,30.5

S,71.5,75.5,91.5,39.5,32

T,74.75,81.25,101.5,39,30

U,74.25,79.75,100,36.5,30

V,73.75,78.25,98,35,30

;

run;

Grand Advisor
Posts: 17,325

Re: Find most similar record

You can look at propensity score matching, there's a macro on the Mayo Clinic website.

The score should give you an indicator of how well it matches.

Ask a Question
Discussion stats
  • 1 reply
  • 147 views
  • 0 likes
  • 2 in conversation