Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From   Beatrice Crozza <beatrice.crozza@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: How to sum two whole rows by date and time
Date   Wed, 3 Aug 2011 17:39:44 +0100

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index