|
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:
>one more complexity to this---I need it to produce an individual level score
>for each person (for each ID in my data), not team level score.
>So this score will differ for each person on the team. Below is an excerpt
>from an article that used this measure that explains this in words:
>
>**********************
>Tsui, Egan, Oreilly 1989. Being Different. Administration Science Quarterly.
>
>
>The relational demography score is the difference between an individual and
>all other individuals in the work unit (i.e., the sample) on a specific
>demographic attribute, using a formula similar to that used by O'Reilly,
>Caldwell, and Barnett (1989) and by Tsui and O'Reilly (1989). It is the
>square root of the summed squared differences between an individual S,'s
>value on a specific demographic variable and the value on the same variable
>for every other individual Si in the sample for the work unit, divided by
>the total number of respondents in the unit (n). The following formula was
>used for this calculation:
>
>SQRT of (1/n)*[SUM (Si - Sj)**2]
>
>i=target individual member
>J=each other team members
>
>A relational measure was derived for each demographic variable. Differences
>in age, company tenure, and education were measured in years. Differences in
>gender and race were measured by a score ranging from zero to approaching
>but never reaching 1.00. For example, a man in a work unit of two men and
>three women would have a relational score of .77 on gender, 0 for being the
>same as the other man and 3 for being different from each of the three
>women. We would then divide the score of 3 by 5 and take the square root of
>the result. Each of the two women, in turn, would have a relational score of
>.63. A score of .999 could be obtained by someone who is the sole minority
>member (on either gender or race) in an extremely large group .4
>
>The relational score on race was computed by considering the differences
>among all the racial groups in the work unit. In a work unit with one
>African-American, one Asian, and two whites, the relational score for the
>African-American and the Asian, respectively, would be 3 (1 for being
>different from each other and 2 for being different from each of the two
>whites), 2 for each of the two whites (1 for being different from the
>African-American, 1 for being different from the Asian, and 0 for being
>different from each other).
>
>All the relational measures were scaled in such a way that a large value
>always connotes a large difference. The individual with a large score on a
>relational measure differs more, in terms of that-specific demographic
>attribute, from other individuals in the work unit (i.e., the sample) than
>another individual with a small score. The actual scores observed on the
>relational age and tenure measures ranged from zero to 30 and on the
>relational education measure ranged from zero to 15. The actual scores
>ranged from zero to .99 for both the relational gender and race measures.
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of toby
>dunn
>Sent: Thursday, January 04, 2007 9:04 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Calculating differences between team members
>
>Data Have ;
>Infile Cards ;
>Input ID Team Member Attitude ;
>Cards ;
>1 1 1 4
>2 1 2 5
>3 1 3 5
>4 2 1 3
>5 2 2 4
>6 2 3 2
>;
>Run ;
>
>Data Need ( Drop = Lastatt ) ;
>Set Have ;
>By Team ;
>Retain Sum ;
>
>LastAtt = Lag( Attitude ) ;
>
>If Not First.Team Then Do ;
> Sum = Sum + ( Attitude - LastAtt )**2 ; End ;
>
>If Last.Team Then Do ;
> Output ;
> Sum = 0 ;
>End ;
>
>Run ;
>
>
>Proc Print
>Data = Need ;
>Run ;
>
>
>
>Toby Dunn
>
>To sensible men, every day is a day of reckoning. ~John W. Gardner
>
>The important thing is this: To be able at any moment to sacrifice that
>which we are for what we could become. ~Charles DuBois
>
>Don't get your knickers in a knot. Nothing is solved and it just makes you
>walk funny. ~Kathryn Carpenter
>
>
>
>
>
>
>From: Tara Wernsing <twernsing@YAHOO.COM>
>Reply-To: Tara Wernsing <twernsing@YAHOO.COM>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Calculating differences between team members
>Date: Thu, 4 Jan 2007 08:50:21 -0600
>
>Yes, of couse. Here is sample layout:
>
>ID team member attitude
>1 1 1 4
>2 1 2 5
>3 1 3 5
>4 2 1 3
>5 2 2 4
>6 2 3 2
>
>
>-----Original Message-----
>From: Jack Clark [mailto:JClark@chpdm.umbc.edu]
>Sent: Thursday, January 04, 2007 8:44 AM
>To: 'Tara Wernsing'; SAS-L@LISTSERV.UGA.EDU
>Subject: RE: Calculating differences between team members
>
>Tara,
>
>Could you provide some sample data to the list?
>
>The suggested solutions will vary depending on the layout of your data. For
>example, does a single observation represent the team or an individual
>person?
>
>
>Jack Clark
>Research Analyst
>Center for Health Program Development and Management University of Maryland,
>Baltimore County
>
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tara
>Wernsing
>Sent: Thursday, January 04, 2007 9:09 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Calculating differences between team members
>
>Hi all~
>I am trying to calculate a formula where I need the sum of the squared
>differences between 3 people on a team (I have 24 teams of 3 people) for the
>same variable.
>
>so for example, for attitude toward a team project, I need to calculate the
>value of one team member's attitude score subtracted from the second member,
>and then subtracted from the third member.
>then square each difference, and sum up all three sq differences.
>
>I can figure out the latter part, but having trouble figuring out how I can
>hold the first person's value in memory, while getting the second person's
>value (could use _point ?) and doing the subtraction but then also a needing
>the third person's value (can I use another _point--can't seem to figure out
>how in the same do loop)?
>
>any ideas are appreciated! thanks, Tara
>
>Tara Wernsing
>Doctoral Candidate
>University of Nebraska-Lincoln
>Gallup Leadership Institute
> <http://www.gli.unl.edu/> www.gli.unl.edu
>--
>"People take different roads seeking fulfillment and happiness. Just because
>they're not on your road doesn't mean they have gotten lost." ~Cesare di
>Bonesana Beccaria
>
>_________________________________________________________________
>Get live scores and news about your team: Add the Live.com Football Page
>www.live.com/?addtemplate=football&icid=T001MSN30A0701
|