Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: How to find the sum of a variable by a group id
From
Urmi Bhattacharya <[email protected]>
To
[email protected]
Subject
st: How to find the sum of a variable by a group id
Date
Tue, 2 Aug 2011 12:05:01 -0400
Dear Statalisters,
I have the following data set.
hhid childid y1
1 1 1
1 2 1
1 3 0
2 1 0
2 2 0
I need to find the sum of y1 per hhid, i.e., i need to get the
following data set
hhid sumy1
1 2
2 0
How do I get that?
I tried the following
collapse (sum) y1, by hhid
it gives me the following error:
option by incorrectly specified
r(198);
I am using Stata 11.2.
It is a simple enough thing I am sure, but I am just not able to work
it out. It would be great if someone could tell me where am i going
wrong?
Best
Urmi
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/