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, statalist.org is already up and running.


[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   Erik Aadland <erikaadland@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: How to convert variable values in tables and panels to CPI adjusted values
Date   Thu, 16 Jun 2011 13:11:35 +0000

Thank you so much Maarten.
 
I will check it out right away.
 
Kind regards,
 
Erik.
 


----------------------------------------
> Date: Thu, 16 Jun 2011 14:54:03 +0200
> Subject: Re: st: How to convert variable values in tables and panels to CPI adjusted values
> From: maartenlbuis@gmail.com
> To: statalist@hsphsun2.harvard.edu
>
> 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/ 		 	   		  
*
*   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