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" <>
To   "Stata Forum" <>
Subject   st: Store cross-section means of stacked data
Date   Tue, 25 Oct 2005 17:16:59 +0200

Dear Stata-Users,

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

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
=2E    .    .
=2E    .    .
=2E    .    .
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 Dovern
D=FCsternbrooker Weg 148
24105 Kiel
Phone: +49-(0)431-1608746
Mobile: +49-(0)176-21532822

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index