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

Hi!
I am trying to calculate Bray Curtis Dissimilarity in SAS by proc distance.

I found an example on the next page:https://www.statisticshowto.datasciencecentral.com/bray-curtis-dissimilarity/

According to the Formula, the result must be 0.39
The same numbers I am getting in the R vegan.

Proc distance producing different results.

data c;
infile datalines;
input id $ A1 A2 A3 ;
datalines;
Fish_1 6 7 4
Fish_2 10 0 6
;
run;
proc distance data=c method=blwnm; 
var ANOMINAL( A: ) ;
id id;
run;

Results:

idFish_1Fish_2
Fish_10 
Fish_20,60


What am I doing wrong here?

Thanks,
   Andrii

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @andrii and welcome to the SAS Support Communities!

 

Thanks for this interesting question. I didn't know this specific dissimilarity measure.

 

In the PROC DISTANCE documentation (close to the bottom of that page) I found that the formula SAS uses with method=blwnm is not equivalent to your linked formula. However, SAS provides an equivalent formula with method=nonmetric. Actually, the formula looks different, but it's an easy exercise to show that it's equivalent (hint: abs(x-y)=x+y-2*min(x,y)).

 

So, in order to replicate your result, use this code:

proc distance data=c out=want method=nonmetric;
var ratio(a:);
id id;
run;

(Note that level "ratio" is required for method=nonmetric.)

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @andrii and welcome to the SAS Support Communities!

 

Thanks for this interesting question. I didn't know this specific dissimilarity measure.

 

In the PROC DISTANCE documentation (close to the bottom of that page) I found that the formula SAS uses with method=blwnm is not equivalent to your linked formula. However, SAS provides an equivalent formula with method=nonmetric. Actually, the formula looks different, but it's an easy exercise to show that it's equivalent (hint: abs(x-y)=x+y-2*min(x,y)).

 

So, in order to replicate your result, use this code:

proc distance data=c out=want method=nonmetric;
var ratio(a:);
id id;
run;

(Note that level "ratio" is required for method=nonmetric.)

andrii
Calcite | Level 5

Hi @FreelanceReinh 

Yes, it exactly what I have been looking for!

Thanks a lot!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 1677 views
  • 1 like
  • 2 in conversation