BookmarkSubscribeRSS Feed
jdub
Calcite | Level 5

Hello

I am trying to 'invert' distance values from a proc distance so the output would correspond to the highest distance value would be coded as zero and a distance value of zero would be coded as the highest distance value.  I can do this by multiplying the distance values by -1 and then adding the max value but was looking for an automated way to approach the solution.  Is there an automated way to refer to the maximum value for a variable using a by statement?

For example:

Say you have 72 counties of data for per capita earnings and average education.  You use this data to create a distance matrix using per capita earnings and average education as variables.  Each county has a distance (method=euclid) that ranges from zero to a maximum value.  Is there a way to refer to the maximum value of the distance by county?

thanks

1 REPLY 1
djbateman
Lapis Lazuli | Level 10

I am not very familiar with PROC DISTANCE, but I would think that this might do the trick, even though I'm not exactly sure how your data looks.

If each row has two values (earnings and education), then the inverse would be:

earnings_inv=earnings-max(earnings,education);

education_inv=education-max(earnings,education);

See if that helps.

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!

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.

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