Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: calculation 'cross differences'

 From Nick Cox To "statalist@hsphsun2.harvard.edu" Subject Re: st: calculation 'cross differences' Date Thu, 18 Apr 2013 12:20:09 +0100

```It seems that you want to compare each value with the means of the
others in each group.

This is an FAQ. See

FAQ     . . Creating variables recording prop. of the other members of a group
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
4/05    How do I create variables summarizing for each
individual properties of the other members of a
group?
http://www.stata.com/support/faqs/data-management/creating-variables-recording-properties/

Searching the archives for mentions for this FAQ may also help.

Nick
njcoxstata@gmail.com

On 18 April 2013 11:59, Mario Jose <mariojose276@gmail.com> wrote:

> I have a sample of companies that are subject to different tax rates,
> they are owned by different parent companies. I would like to compute
> differences of tax rates within each group and in the perspective of
> each company. Below is an example of the database and a view of what I
> would like to compute:
>
> group company  taxrate
> 1                 A              15
> 1                 B              10
> 1                 C              20
> 2                 D              20
> 2                 E              15
> 2                 F              14
> 2                 G              30
>
> The task I need to do is calculate the following regarding for
> instance companies A, B and C of group 1:
>
> A=> (15-10) + (15-20)
> B=> (10-15) + (10-20)
> C=> (20-15) + (20-10)
>
> As I have thousands of companies it is a hard to do this manually, is
> there any suggestion on how to handle with this calculations?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```