On Nov 12, 2007 4:11 PM, <[email protected]> wrote:
> Dear all,
>
> Suppose I have 10 scalars, which contain some statistic of 10 variables.
> These scalars are: statistic1, statistic2..... statistic10.
>
> How one can sum a set of these scalars? I mean, let�s assume I want to sum
> statistic3 to statistic7. Ho do one do that?
>
>
> Tiago
>
> P.S. I would like to thank Kit and Joseph for their help on my last post.
> Thank you very much.
>
I think the example below may do the job Tiago wants to do, though
others may have a better solution for Tiago.
** Begin example ****
* Create 10 scalars
forv i=1/10 {
scalar myscal`i'=`i'+3
di "scalar =", myscal`i'
}
* Or if you will
scalar list
* Now let's sum them
local i=1
scalar mysum=0
while `i'<=10 {
scalar mysum= mysum + myscal`i'
local i=`i'+1
}
di mysum
** End example *****
Hope this helps
--
P. Wilner Jeanty, Post-doctoral researcher
Dept. of Agricultural, Environmental, and Development Economics
The Ohio State University
2120 Fyffe Road
Columbus, Ohio 43210
(614) 292-6382 (Office)
*
* 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/