[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: Summing up values specific for each individual.
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
> > 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 email@example.com 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.
* For searches and help try: