Right, but I would like to add this new variable with to rest of the
dataset, rather than creating a new one.  I realize I can collapse and
then merge, but is there a way to do it in one step?
On 5/9/06, Martin, Aurelie <[email protected]> wrote:
collapse (sum) A, by (ID)
replace  ID=3 if ID==2
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Amber Katz
Sent: Tuesday, May 09, 2006 1:59 PM
To: statalist
Subject: st: Summing variables over all observations by identifier
Hi,
I'm looking for a function that will sum a variable across all
observations by identifier.
For example, if I have
ID  A
1   1
1   0
2   1
2   2
I would like a function that would give me:
SumByID=function(A,ID)
SumbyID would be equal to 1 for all observations with ID=1 and 3 for all
observations with ID=2 .
Thanks very much,
Rachel
*
*   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/
*
*   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/