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

st: summation


From   "A. Mobarak" <[email protected]>
To   <[email protected]>
Subject   st: summation
Date   Fri, 9 Dec 2005 00:55:16 -0700

Dear All,

I post a part of my dataset below.  I would like to sum the variable
"length" from n=min to n=max for each state, where n, min and max are 3
different variables.  I'm using Stata8SE. 

So, for example, for state=1, the answer I'm looking for would be:

summation (n going from 2 to 20) of "length', which equals
10+20+30+....+190 = 1900

For state=3, the answer would be summation (n going from 6 to 16) of
length = 50+60+.+150 = 1100

For state=2, I would just get "." (missing)

This is a very large dataset, which is why I need to automate the
summing procedure. I apologize in advance if the answer is obvious.  I
will be grateful for any help or suggestions.  I subscribe to the digest
version, so copying the response to [email protected] (hitting "reply
all" rather than "reply" may also work) will help me get your response
quicker.

group	n	min	max	state	length
3	2	2	20	1	10
3	3	.	.	2	20
3	4	2	20	1	30
3	5	2	20	1	40
3	6	6	16	3	50
3	7	2	20	1	60
3	8	6	16	3	70
3	9	2	20	1	80
3	10	6	16	3	90
3	11	2	20	1	100
3	12	6	16	3	110
3	13	2	20	1	120
3	14	6	16	3	130
3	15	2	20	1	140
3	16	6	16	3	150
3	17	17	25	4	160
3	18	2	20	1	170
3	19	17	25	4	180
3	20	2	20	1	190
3	21	17	25	4	200
3	22	22	28	5	210
3	23	17	25	6	220
3	24	22	28	5	230
3	25	17	25	6	240
3	26	22	28	5	250
3	27	.	.	7	260
3	28	22	28	5	270


Thanks!

A. Mushfiq Mobarak
Assistant Professor of Economics
University of Colorado at Boulder
303-492-8872
www.colorado.edu/Economics/courses/mobarak




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