Statalist The Stata Listserver


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

Re: st: Summing variables over all observations by identifier


From   Philipp Rehm <[email protected]>
To   [email protected]
Subject   Re: st: Summing variables over all observations by identifier
Date   Tue, 09 May 2006 20:08:46 +0200

bys ID: egen SumByID=sum(A)

HTH,
Philipp

Amber Katz wrote:
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/



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