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/