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

st: RE: Store cross-section means of stacked data


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Store cross-section means of stacked data
Date   Tue, 25 Oct 2005 17:19:40 +0100

If you put these values into a matrix, 
you will just create a problem for later
of how to extract them, especially for 
plotting. 

You should be aware of -collapse- 
and -egen, tag()-. The former cuts
out the repeated storage, at the 
cost of losing other data that may be 
interesting or important. The latter
lets you select just one of every 
group so that graphs are not based
on the same information repeated 
several times. 

Nick 
[email protected] 

Jonas Dovern
 
> 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?

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