assuming Stata 7
bysort HHid: egen totalcons=sum(amount_consumed)
Quoting Kompal Sinha <[email protected]>:
> Dear All,
>
> 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
>
> 501 2 2
> 501 5 3
> 501 6 1
> 501 8 5
> 501 10 6
> 501 11 2
>
> 502 2 5
> 502 6 8
> 502 7 2
> 502 13 9
> 502 15 3
> 502 16 5
> 502 1 3
>
>
>
> 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.
> I thank you for your help in advance.
>
> Sincerely,
> Kompal Sinha.
>
> *
> * 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/