Hi Thomas,
The trick is to generate a year indicator and then to collapse on it:
. gsort -month
. gen x=1 if mod(month,12)==0
(22 missing values generated)
. gen year=sum(x)
. list
+-----------------------------+
| month var1 x year |
|-----------------------------|
1. | 24 6.420962 1 1 |
2. | 23 6.359303 . 1 |
3. | 22 6.291237 . 1 |
4. | 21 6.216306 . 1 |
5. | 20 6.13373 . 1 |
|-----------------------------|
6. | 19 6.043005 . 1 |
7. | 18 5.943435 . 1 |
8. | 17 5.834095 . 1 |
9. | 16 5.714371 . 1 |
10. | 15 5.584059 . 1 |
|-----------------------------|
11. | 14 5.443335 . 1 |
12. | 13 5.291652 . 1 |
13. | 12 5.129404 1 2 |
14. | 11 4.959064 . 2 |
15. | 10 4.785601 . 2 |
|-----------------------------|
16. | 9 4.612175 . 2 |
17. | 8 4.443652 . 2 |
18. | 7 4.280849 . 2 |
19. | 6 4.142096 . 2 |
20. | 5 4.063006 . 2 |
|-----------------------------|
21. | 4 4.069176 . 2 |
22. | 3 4.171527 . 2 |
23. | 2 4.27602 . 2 |
24. | 1 3.407265 . 2 |
+-----------------------------+
. collapse (sum) var1, by(year)
. list
+-----------------+
| year var1 |
|-----------------|
1. | 1 71.27549 |
2. | 2 52.33984 |
+-----------------+
rafal
================
Rafal Raciborski
Graduate student
Department of Political Science
Emory University
301 Tarbutton Hall
1555 Dickey Drive
Atlanta, GA 30322
404-378-9826 (home)
[email protected] (e-mail)
www.roofoos.net
*
* 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/