Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: RE: st: RE: summation


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: RE: st: RE: summation
Date   Mon, 12 Dec 2005 17:11:24 +0000

You did point out in your original that you
were using Stata 8. Provided that you have
updated properly, the -levels- command should
do what -levelsof- does. -levels- was originally
user-written, then adopted by Stata in the lifetime
of Stata 8, then renamed -levelsof- in Stata 9.

Nick
[email protected]

A. Mobarak

Thank you for your post. The fact that "length" was in multiples of 10
were just numbers I made up to quickly provide an example, and the real
data has no such pattern.  However, I did find a general solution using
the -sum- function, with the help of Patricia McManus and Randall Kuhn,
who replied to me privately.  The solution is:

bysort group: gen s=sum(length) if max~=.
by group: gen sumlength=s[max]-s[min]

The program Nick Cox wrote the first day would also presumably work (all
the steps and the logic looked right to me), but I'm still on Stata8,
which doesn't offer the -levelsof- command that he used in that program.
I replaced the "levelsof" with an -egen group-, but I still couldn't get
it to work, probably because of some mistake I was making in running it.

Thank you all for taking the time to think about and write about this
problem.
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index