Date: Fri, 5 Jan 2007 15:24:57 -0500 "Howard Schreier " "SAS(r) Discussion" "Howard Schreier " Re: FW: Calculating differences between team members

David has pointed out that the formula hear can be converted into formula involving summary statistics with no reference to individual terms. So that would be the way to go.

However, when it is necessary to find a more do-it-yourself solution to a problem like this, reflexive joins are usually handy. Using Tara's problem to illustrate ...

Test data:

data have; do time = 1 to 3; do team = 1 to 3; do member = 1 to 5; attitude = ceil(5*ranuni(1) ); output; end; end; end; run;

Compute:

proc sql; create table scored as select self.time , self.team , SQRT( (1 / count(*) ) * SUM( (self.attitude - other.attitude) ** 2) ) as score from have as self join have as other on self.time = other.time and self.team = other.team and self.member ^= other.member group by self.time, self.team ; quit;

On Thu, 4 Jan 2007 10:22:21 -0600, Tara Wernsing <twernsing@YAHOO.COM> wrote: