It's the manual you need, not the archives.
The annual average for 2000 is given by
su X if tin(2000q1,2000q4)
after which your scaling appears to be
gen X2000 = X / r(mean)
Hence for lots of variables you would
go
qui foreach v of var <varlist> {
su `v' if tin(2000q1,2000q4), meanonly
gen `v'2000 = `v' / r(mean)
}
Nick
n.j.cox@durham.ac.uk
Michael S. Hanson
> series variables in a Stata dataset. The observations are quarterly,
> and all need to be rebased (for example) to the annual average value
> for (say) the year 2000. The following code will find that average
> value:
>
> egen Xavg = mean(X) if tin(2000q1,2000q4)
>
> But of course the variable Xavg here is only defined for the
> 4 quarters
> in 2000, and is missing everywhere else. Hence, the following code
> only returns values for 2000, rather than the 30 years of quarterly
> observations in the sample.
>
> gen X2000 = X / Xavg
>
> (Yes, we're indexing to 2000 = 1 instead of 2000 = 100; this scale
> factor has no subsequent effect on the analysis.)
>
> There are a large number of series to rebase, and their
> starting date
> varies; hence, attempting to use a [_n] construct seems not to work,
> as the observation numbers that represent the year 2000 vary
> across the
> series.
>
> A look through the Statalist archives and with -findit-
> didn't turn up
> any obvious hints, although it's quite possible I missed something
> relevant. Thanks in advance for any assistance.
*
* 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/