The by option for collapse can take more than one variable so all you need
to do is: collapse(sum) amount, by (area candid) to get what you are looking
for. Cheers, Steve
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Harriet Baker
Sent: Sunday, 15 April 2007 1:04 p.m.
To: [email protected]
Subject: st: Collapse (sum) observations by two variables?
Hello,
I am working on a project with contributors to candidates. I would
like to sum contributions within a given geographic area (zip code)
to a given candidate. If I only had one candidate, then I would
collapse(sum) amount, by (area). However, I have over 1000
candidates in the data. Is there a way that I can collapse sum with
two conditions?
My data is structured as follows
Candid Amount Area
1 10 a
1 20 b
1 70 c
1 10 b
2 20 c
2 10 a
2 30 c
2 20 b
3 40 c
3 60 a
3 40 b
3 10 a
I want:
1 a 10
1 b 80
1 c 70
2 a 10
2 b 20
2 c 50
Does anyone know how I might do this? Thank you.
Harriet Baker
Duke University
Political Science
*
* 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/
*
* 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/