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 convert variable values in tables and panels to CPI adjusted values
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: How to convert variable values in tables and panels to CPI adjusted values
Date
Thu, 16 Jun 2011 14:54:03 +0200
On Thu, Jun 16, 2011 at 2:38 PM, Erik Aadland wrote:
> I need to convert variable values in tables and panels to CPI (consumer price index) adjusted values.
*--------------------- begin example -----------------------
// create datasets
clear all
tempfile cpi annual panel
input year cpi
1997 0.9
1998 1
1999 1.2
2000 1.3
end
save `cpi'
drop _all
input ///
year var1 var2
1997 2.1 2.2
1998 3.3 4.3
1999 4.3 4.0
2000 3.7 3.8
end
save `annual'
drop _all
input ///
year org_id var1 var2
1997 1 2.1 2.2
1998 1 2.2 2.3
1999 1 2.3 2.4
1998 2 1.5 1.6
1999 2 1.6 1.7
end
save `panel'
// start correcting the annual data
use `annual'
merge 1:1 year using `cpi'
list
assert _merge == 3
drop _merge
gen cvar1 = var1/cpi
gen cvar2 = var2/cpi
list
// start correcting the panel data
use `panel', clear
merge m:1 year using `cpi'
list
assert _merge != 1
drop if _merge == 2
drop _merge
gen cvar1 = var1/cpi
gen cvar2 = var2/cpi
list
*---------------------- end example -------------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )
Hope this helps,
Maarten
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://www.maartenbuis.nl
--------------------------
*
* 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/