[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Michael S. Hanson" <mshanson@mac.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Reindex/rebase time series? |

Date |
Thu, 14 Apr 2005 17:21:29 -0400 |

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.

-- Mike

*

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

- Prev by Date:
**st: RE: RE: Fitting a t distribution** - Next by Date:
**st: RE: RE: RE: Fitting a t distribution** - Previous by thread:
**st: stcurve after streg with ancillary parameters** - Next by thread:
**st: RE: RE: RE: Fitting a t distribution** - Index(es):

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