Kompal Sinha asked
> > I am working with household data and my problem is
> something like this.
> >
> > For each household I have 'j' items where 'j' varies for
> each household. I
> > want to find the sum of these items for each household.
> >
> > For example:
> >
> > HHid item code amount consumed
> >
[ ... ]
> >
> > In the above example I want to find the sum of the third
> column(amount
> > consumed) for each household and place this sum in the
> fourth column such
> > that the sum is repeated '
> > j' times for one household. As I have 69000 households, I
> wonder if there is
> > a command or a program is STATA that can do this for me.
> Also the number of
> > items consumed by each household varies.
and sorensen@mit.edu rightly wrote
> assuming Stata 7
>
> bysort HHid: egen totalcons=sum(amount_consumed)
More generally, the tool you want and need
is -by <varlist>:-. Typing
. findit by
in an up-to-date Stata points to sources
of information in the manual and elsewhere.
Nick
n.j.cox@durham.ac.uk
*
* 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/