Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Price Index

From   Nick Cox <>
To   "''" <>
Subject   st: RE: Price Index
Date   Tue, 5 Apr 2011 18:26:40 +0100

Let me outline solutions for two situations. 

1. Suppose you have a single item whose price you are monitoring. 


su price if time == 495

gen priceindex = 100 * price / r(mean) 

I am clearly assuming that you want 100 as your base. 

2. However, I imagine you would not be asking if that was the problem. Your question implies something like a panel structure. 

Then you could reach for something more like 

egen priceindex = total(price / (time == 495)), by(panelid) 


egen priceindex = total(price * (time == 495)), by(panelid)

followed by 

replace priceindex = 100 * price / priceindex 

The logic is that -time- of 495 occurs just once in each panel. You should check that. 

You could squeeze that into one command, no doubt, but I guess with some loss of clarity. 



I need to create a price index using a base price.
How can I indicate to Stata to use always the same observation as a base (in my example time==495)?
For example, my variables are:
time price
495 20
496 22
497 23

*   For searches and help try:

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