<>
My solution does extend to the panel case in exactly the fashion which you
describe. Am I missing something else in your request?
********
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
2 1990 100 25 29
2 1991 500 60 13
2 1992 0 0 .
2 1993 . . .
2 1994 600 300 60
end
compress
list, noobs
bys id: gen newV3=/*
*/ sum(V3)/sum(V3!=.)
list, noobs
********
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von SERGIO MOISES
AFCHA CHAVEZ
Gesendet: Mittwoch, 15. Juli 2009 20:35
An: [email protected]
Betreff: st: RE: Average for panel data
Dear Martin Weiss,
Thanks for your fast response, but I think I explain my question badly:
In your solution:
gen newV3=sum(V3)/sum(V3!=.)
Sum (V3) is a sum of all observations, I have a panel data, so, the Id
variable
continue with 2,3....3500 and I need the average variable for every
individual in my database. I think I could obtain this with:
by id: gen newV3=sum(V3[_n])
But, I don't know how continue with that, I need to divide this between the
number of the years with valid observation, and I don't know how express
this
with STATA.
Thanks,
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/