
From  David Kantor <kantor.d@att.net> 
To  statalist@hsphsun2.harvard.edu 
Subject  Re: st: using matrix expression 
Date  Tue, 03 Oct 2006 12:00:06 0400 
At 03:42 PM 10/2/2006, Sayda G Wentworth wrote:
Hi,
I have thousands of observations (individuals) and earnings data for each of them covering 53 years, in the form earnings1951, earnings1952,...,earnings2003.
I'd like to convert those nominal earnings to 2003 dollars.
I have a price index variable called cpi with 53 values * for each of the 53 years, where the first value is equal to cpi1951/cpi2003, the second is cpi1952/cpi2003 etc. The remaing values are missing (because I copied a column created in excel).
I'm trying to write a mini program that'll compute real earnings (in 2003 dollars) for all individuals the following way:
gen j=0
. program define real
1. local i=1951
2. while (`i'<=2003) {
3. replace j=`i'1950
4. gen realearnings`i'=earnings`i'/cpi[`j',1]
5. local i=`i'+1
6. }
7. end
But the results I get are incorrect. To check why, I try:
gen realearnings1951=earnings1951/cpi[1,1]
and get an error message saying:
cpi not found
r(111);
What is the correct way of doing this computation?
Thanks.
© Copyright 1996–2017 StataCorp LLC  Terms of use  Privacy  Contact us  What's new  Site index 