Statalist


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

st: RE: Average for panel data


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: Average for panel data
Date   Wed, 15 Jul 2009 19:22:35 +0200

<>

***
clear*

input  id	Year	V1	 V2	V3   
1	1990	100	25	25
1	1991	500	60	12
1	1992	0	0	.
1	1993	.	.       .
1	1994	600	300	50 
end

compress
list, noobs  

gen newV3=sum(V3)/sum(V3!=.)

list, noobs
***



HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of SERGIO MOISES
AFCHA CHAVEZ
Sent: Mittwoch, 15. Juli 2009 19:36
To: [email protected]
Subject: st: Average for panel data

Dear statalisters,
I am working with an unbalanced panel Data. I'm trying to generate an
average
measure with a database similar to this:
Id	Year	V1	 V2	V3=(v2/v1)       
1	1990	100	25	25
1	1991	500	60	12
1	1992	0	0	.
1	1993	.	.       .
1	1994	600	300	50
The average that I need should be the cumulative sum of the variable V3
divided
between the number of  years with values different from 0 or missing. For
example:
year1990: (25/1)
year1991: ((25+12) /2)
year 1992: ((25+12)/2)
year 1993: ((25+12)/2)
year 1994: ((25+12+50) /3)
Only considering those years with information different from 0 or missing
value. 
Thanks in advance for your help,
Sergio




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

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

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index