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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: Price Index


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
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. 

Then 

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) 

or 

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. 

Nick 
n.j.cox@durham.ac.uk 

A.Silva

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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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