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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: Problem with simple descriptive statistics |

Date |
Tue, 7 Jul 2009 15:11:05 +0200 |

<> On -bysort-, Chris also wants to consult the canonical reference by NJC: http://www.stata-journal.com/sjpdf.html?articlenum=pr0004 HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Stata Chris Gesendet: Dienstag, 7. Juli 2009 14:54 An: statalist@hsphsun2.harvard.edu Betreff: st: Problem with simple descriptive statistics Dear Statalisters, I have a problem with the bysort syntax (or so I think). For a set of 18 investment funds, I am trying to figure our for each period what share of their total assets are held in different asset classes, using the following code. The idea was first to compute holdings of each asset class (as specified by "assetclassno") and period, while summing across all funds and individual assets. Then I wanted to sum these across all assetclassno for each period, in order to then compute what share of the total holdings in that period fell to each assetclassno. And then I wanted to look at the results for one specific period. Here's the code: bysort period assetclassno: egen holdings = sum(value) bysort period: egen total = sum(holdings) bysort period assetclassno: gen perc = 100 * holdings/total preserve keep if period==456 bysort assetclassno: sum perc egen test = sum(perc) sum total sum test restore The problem is that the fractions I get for the different assetclassno (not all assetclasses are being held in that period though) in period 456 are all way too small, and they don't actually add up to what I'm being told is the total. Strangely though, the test number is still 100. Does anyone see where my mistake is? Many thanks and all best, Chris * * 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/ * * 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/

**References**:**st: Problem with simple descriptive statistics***From:*Stata Chris <statachris@gmail.com>

- Prev by Date:
**Re: st: data points within radius?** - Next by Date:
**st: AW: Problem with simple descriptive statistics** - Previous by thread:
**st: Problem with simple descriptive statistics** - Next by thread:
**st: AW: Problem with simple descriptive statistics** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |