BookmarkSubscribeRSS Feed
grodman
Obsidian | Level 7

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;

1 REPLY 1
Reeza
Super User

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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