BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shanmugavel_g
Calcite | Level 5

Hi All,

 

I'm trying to run KNN on set of standardized inputs and identify 20 neighbors using Euclidean distance or other similar distance. 

I would like to get top N neighbor, distance between the neighbors and my item as output. I don't have a target variable in my dataset, so I need this procedure to identify my neighbors based only on input space. I have 21K items and 145 variables in my dataset, so I'm also looking for efficiency of the procedure.

 

I tried MBR node in Enterprise miner and PROC DISCRIM in base SAS, but both requires target variable. 

Can anyone kindly point me to the right procedure that would be helpful to implement my problem. Let me know if any other details are needed.

 

Thanks in advance

 

Regards,

Shan

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try using proc modeclus with options neighbor and dk=

 

ods _all_ close;
proc modeclus data=myData dk=21 neighbor;
var var1-var145;
id Item;
ods output Neighbor=myNeighbors;
run;
ods listing;

test with a subset first!

PG

View solution in original post

5 REPLIES 5
Shanmugavel_g
Calcite | Level 5

Thanks for quick reply. I will take a look into these procedure, run it on my data and will let you know the results.

PGStats
Opal | Level 21

Try using proc modeclus with options neighbor and dk=

 

ods _all_ close;
proc modeclus data=myData dk=21 neighbor;
var var1-var145;
id Item;
ods output Neighbor=myNeighbors;
run;
ods listing;

test with a subset first!

PG
Shanmugavel_g
Calcite | Level 5
Thanks for quick reply.
I'll try your code on my dataset and let you know the results. Thanks for the help.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 2858 views
  • 4 likes
  • 4 in conversation