Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

st: RE: How to sum two whole rows by date and time

 From "Cohen, Elan" To statalist Subject st: RE: How to sum two whole rows by date and time Date Wed, 3 Aug 2011 17:10:24 +0000

```collapse (sum) x y d1 d2 d3 dup, by(date time)

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Beatrice Crozza
> Sent: Wednesday, August 03, 2011 12:40
> To: statalist
> Subject: st: How to sum two whole rows by date and time
>
> Dear All,
>
> maybe it is an easy problem to solve, but I cannot find a way to sort it out!
>
> I would like to sum the entries of two rows:
>
> date              time       x        y    d1    d2 d3  dup
> 23/01/2008     9:05     99.8           1      .   .      1
> 23/01/2008     9:05         .       5    .      1   1     2
>
> i would like to sum by date and time, in order to have:
>
> date              time       x        y    d1    d2 d3  dup
> 23/01/2008     9:05       99.8      5    1     1   1     3
>
>
> It is not always the case that, for example, one row has the price, in
> other words there is not regularity, otherwise I could have used a
> time operator to replace the row with the previous one.
>
> I also tried with collapse (sum) but i receive the error message that
> a variable cannot be both target and by() and I haven't found a
> command similar to egen rowtotal for summing columns.
>
> Thank you very much for any help.
>
> Bea
> *
> *   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/

*
*   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/
```