Bookmark and Share

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.


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

st: Dataset of means from the three largest values of a group


From   Iulian Ihnatov <iulian.ihnatov@uaic.ro>
To   statalist@hsphsun2.harvard.edu
Subject   st: Dataset of means from the three largest values of a group
Date   Mon, 28 Nov 2011 22:03:07 +0200

Dear Statalisters,
I have the following dataset for the period of 1999 to 2010:
country    year     partner     trade
AFG          1999    USA          12345
AFG          1999    DEU          9875
AFG          1999    FRA           25487
........................
AFG          2000    USA           5454
AFG          2000    HUN          5454
........................
HUN         1999    DEU           58744
........................

I need to create a dataset of means of the "trade" variable, grouped by country and year, but only for the three largest observations of each group. I may use - collapse (mean) trade, by(country year) -, but I don't know how to isolate the largest three values from each group (in some years, there are only 1 or 2 observations available, in others more than 10). Any help would be highly appreciated.

--
Iulian Ihnatov
"Al.I.Cuza" University of Iasi


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index