[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Ulrich Kohler <[email protected]> |

To |
[email protected] |

Subject |
Re: st: aggregate identical observations |

Date |
Fri, 12 Dec 2003 13:11:37 +0100 |

How about: by pref1 pref2, sort: replace wgt = sum(wgt) by pref1 pref2: keep if _n == _N regards uli Dietrich Dr�ner wrote: > I need to aggregate the number of observations in my data set when they > have identical values on two variables AND I need to sum up the values of a > third variable so that it remains the same for the reduced data set. I will > try to illustrate this and also describe the substantial problem: > > my initial data matrix looks like this: > > act wgt pref1 pref2 > 1 4 100 0 > 2 5 33 0 > 3 3 33 50 > 4 3 100 50 > 5 10 33 0 > 6 10 33 100 > 7 5 33 50 > 8 3 33 50 > 9 10 33 50 > 10 2 33 50 > 11 5 33 0 > 12 5 33 50 > 13 8 33 50 > 14 4 100 0 > 15 10 33 50 > 16 100 70 > 17 100 70 > > sum 87 > > The first variable is the number of my actors (the 15 EU member states plus > the European Commission and the European Parliament). The second variable > is the voting weights of the member states. The third and fourth variables > are preferences of the actors in two dimensions. Many of the actors have > identical preference profiles that I need to aggregate. > > The result of this aggregation should look like this: > > act wgt pref1 pref2 > 1 8 100 0 > 2 20 33 0 > 3 46 33 50 > 4 3 100 50 > 5 10 33 100 > 6 100 70 > > sum 87 > > > How can I do this in Stata (7)? > > Thank you! > > Regards, > > Dietrich. > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Dietrich Dr�ner > Schneckenburgstr. 24 > D - 78467 Konstanz > > Tel. (+49) - 7531 - 698003 > Fax (+49) - 1212 - 522970813 > Mob.(Inland): (+49) - 177 - 6334099 > Mob.(Ausland):(+49) - 162 - 7679952 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > * > * For searches and help try: > * http://www.stata.com/support/faqs/res/findit.html > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ -- [email protected] +49 (030) 25491-361 * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: aggregate identical observations***From:*"Nick Cox" <[email protected]>

**References**:**st: aggregate identical observations***From:*Dietrich Dr�ner <[email protected]>

- Prev by Date:
**Re: st: general statistical reasoning question in biomedical statistics(no Stata content)** - Next by Date:
**st: what is c_local?** - Previous by thread:
**st: aggregate identical observations** - Next by thread:
**RE: st: aggregate identical observations** - Index(es):

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