Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Weighted summing in a loop for members of a group


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Weighted summing in a loop for members of a group
Date   Wed, 23 Mar 2011 17:29:40 +0000

There is a -sum()- function and an -egen- function -total()-. But the
twist for you appears to be the calculation w.r.t. all others in a
group. That is an FAQ:

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/members.html

Nick

On Wed, Mar 23, 2011 at 5:15 PM, Timm Klare <[email protected]> wrote:

> I would appreciate your help in solving the following problem. I work
> on a dataset containing balance sheet and other information about a
> couple of million European companies (AMADEUS).  The data relevant to
> my current problem is made up of the following variables:
>
> GROUP_PARENT    NUM_ID    YEAR    TOTAL_ASSETS    GROUP_TOTAL_ASSETS    TAXRATE
>
> NUM_ID is the unique ID of each company and GROUP_PARENT is the ID of
> the parent company for each group of companies. For each NUM_ID and
> YEAR I need to calculate an new variable. It should sum the
> asset-weighted tax rate differences between each NUM_ID YEAR and all
> other companies in each group:
>
> (sigma sign) (TAXRATE[NUM_ID] – TAXRATE[i])*(TOTAL_ASSETS[i]/GROUP_TOTAL_ASSETS)
>
> Where i corresponds to all other companies in the observed group.
> How can this be done? Is there a “sigma sign” like summing function in
> Stata? I tried using a foreach loop but failed.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index