You could -reshape- again. Alternatively, break
the problem into steps. The geometric mean is
exp(mean(log())).
Let us suppose you have 42 prices.
gen geomean = 0
qui forval i = 1/42 {
replace geomean = geomean + log(price`i')
}
replace geomean = exp(geomean / 42)
So, we get the sum of the logs, then divide by
the number of prices. That is our mean log price,
which we then exponentiate. Your number of prices
will be some other number, presumably.
Nick
[email protected]
U.A.QU.AP <[email protected]>
You will need to get the -egenmore- package from ssc, use -
reshape- to make a single variable
representing price, make a variable telling you the year
(since it appears you have monthly data and you want yearly
means),
than using -egen geomprice = gmean(price), by(year)- to get
the
variable you want.
with your solution it is difficult to create variable year
the new form of my data is:
price1 price2
period:801 100 100
period:802 100.3 100.7
.
.
.
period:032 127 130
given this structure what is the bes way to create a gometric
mean
for periods 801 to 8012; 802 to 811 and so on
note that period 801 denotes price at january 1980
*
* 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/