03-18-2016 03:12 PM
I would like to calculate dissimilarity index with SAS. The formula is the following:
bi is the value of variable b in area i
B is the summation of all bi
w is the value of variable w in area i
W is the summation of all wi.
I was doing the long way, using proc means, output out, etc. but I'm pretty sure there is a easily and quicky way to do this with proc SQL.
I try this codes, but it doesn't work (I don't really know how works the SLQ procedure):
select sum(abs((b/sum(b))-(w/sum(w)))/2 as d1
Can someone please help me?
03-18-2016 04:45 PM
Nevermind, I found the solution:
create table table1 as
select*, b/sum(b) as var1, w/sum(w) as var2
select 0.5*sum(abs(var1-var2)) as d1
03-18-2016 05:26 PM - edited 03-18-2016 06:43 PM
Thanks. And what should I do if I want to add a class statement to calculate many index?
I tried simply adding "group by X" to your codes, but the result is not relevent.
Also, is there a way to store the d1 into an excel file?
03-18-2016 06:50 PM
I would need data to test anything.
And are you lookin to have a "dissimilarity index" within each level of the variable (resulting in multiple indices) or to calculate the index between summarized levels (a single index)?
With a code that doesn't provide what you want it helps to provide the code ran, some input data and the desired result for the example data. If there were errors or warnings in the log those may help as well.
03-18-2016 06:56 PM - edited 03-18-2016 06:57 PM
Here is a short sample of the data
I would like to compute a dissimilatiry index for each county (there is much more observations in county than what I show there) and one global dissimilarity index.
Need further help from the community? Please ask a new question.