BookmarkSubscribeRSS Feed
daradanye
Obsidian | Level 7

Hi,

 

I have a table (matrix) like this:

 

idyearvar1var2var3….var300
11997345 6
11998521 3
……………………………………
12007536 2
21997112 0
……………………………………
22007316 0
31997245 4
 ………………………………
32006043 4
 ………………………………
50001997002 6
……………………………………
50002006312 6

That said, I have a lot of observations and variables.

 

Ideally, I want to calculate pairwise cosine similarity between two observations and output like this:

d1id2yeardistance
121997xx
131997xx
 
150002006xx
211997xx
 
250002006xx
 

 

 

I am exploring proc distance and proc iml but have not figured it out yet.  I will appreciate it very much if someone can help me out here.

 

Thanks!

2 REPLIES 2

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2730 views
  • 2 likes
  • 3 in conversation