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

st: Store cross-section means of stacked data


From   "Jonas Dovern" <[email protected]>
To   "Stata Forum" <[email protected]>
Subject   st: Store cross-section means of stacked data
Date   Tue, 25 Oct 2005 17:24:03 +0200

Dear Stata-Users,

I have the following problem with regard to efficient programming/data storing:

Assume I have a data in stacked form, e.g.:

Country Year Var1
A 1 q
A 2 w
A 3 e
A 4 r
A 5 t
B 1 z
B 2 u
B 3 i
B 4 o
. . .
. . .
. . .
C 5 p

What I want is to compute the average across countries of Var1 for each year - and store these values to make a plot later on. So far I created a new variable, say Mean, and filled it with the mean values. The new variable, however, is also of size #Counties*#Years repeating the entries for each year #Countries-times -- although I would need to store the mean for each year only once.

What is the usual way to perform this task? Store the values in a matrix? Can I easily plot this matrix later on?

Thanks for your help,

Jonas

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