Help using Base SAS procedures

KNN - SAS Procedure to run KNN without target variable

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

KNN - SAS Procedure to run KNN without target variable

[ Edited ]

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


Accepted Solutions
Solution
‎10-12-2016 12:57 PM
Respected Advisor
Posts: 4,930

Re: KNN - SAS Procedure to run KNN without target variable

Posted in reply to Shanmugavel_g

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


All Replies
Super User
Posts: 19,855

Re: KNN - SAS Procedure to run KNN without target variable

Posted in reply to Shanmugavel_g
New Contributor
Posts: 3

Re: KNN - SAS Procedure to run KNN without target variable

[ Edited ]

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

Solution
‎10-12-2016 12:57 PM
Respected Advisor
Posts: 4,930

Re: KNN - SAS Procedure to run KNN without target variable

Posted in reply to Shanmugavel_g

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
New Contributor
Posts: 3

Re: KNN - SAS Procedure to run KNN without target variable

Thanks for quick reply.
I'll try your code on my dataset and let you know the results. Thanks for the help.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 572 views
  • 4 likes
  • 4 in conversation