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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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