Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: How to set a year index?
From 
 
Nick Cox <[email protected]> 
To 
 
"'[email protected]'" <[email protected]> 
Subject 
 
RE: st: How to set a year index? 
Date 
 
Fri, 20 May 2011 15:58:57 +0100 
The logic here is fine, but why do it this way? 
summarize price if year == 2005, meanonly 
gen price_index = price/r(mean)
Note how 
1. The middle macro is completely unnecessary. 
2. Although it will not usually bite, you are probably losing a smidgen of precision by using a local. 
3. Specifying -meanonly- is efficient if all you need is the mean. 
Small points indeed, but in computing the devil is often in the details. 
Nick 
[email protected] 
Oliver Jones
for example if you had a variable called price you could do
summarize price if year == 2005
local base_value = `r(mean)'
gen price_index = price/`base_value'
Am 20.05.2011 16:43, schrieb Barbara Engels:
> I have a time series from 1990 to 2010 and want to set the year 2005 as an index year (2500=100) so as to evaluate the other observations with reference to 2005. How can I do that with Stata commands?
*
*   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/